SNIPPET
2 Upvotes

Lemmatise DataFrame Text Using NLTK

import nltk
nltk.download('wordnet')
from nltk.stem import WordNetLemmatizer
lemmatizer = WordNetLemmatizer()
def lemmatize_words(text):
    words = text.split()
    words = [lemmatizer.lemmatize(word,pos='v') for word in words]
    return ' '.join(words)
df['text'] = df['text'].apply(lemmatize_words)

By detro - Last Updated Oct. 20, 2021, 4:11 p.m.

COMMENTS
RELATED SNIPPETS
Search Snippets by Tag: