Reputation: 33
This is my import:
from nltk.corpus import stopwords
And this is my code:
def stopwords(text):
"""a function for removing the stopword"""
sw = stopwords.words('english')
# removing the stop words and lowercasing the selected words
text = [word.lower() for word in text.split() if word.lower() not in sw]
# joining the list of words with space separator
return " ".join(text)
Applying:
df['col_text'] = df['col_text'].apply(stopwords)
I got this error: AttributeError: 'function' object has no attribute 'words'
Someone can help me with this problem please?
Upvotes: 1
Views: 1336
Reputation: 205
Hello the problem is that you've named your function like the nltk.corpus module. You should find an other name for your function and it'll work I think.
Upvotes: 2