【发布时间】:2019-03-06 19:12:37
【问题描述】:
【问题讨论】:
【问题讨论】:
我认为您要删除的是“to”、“the”等停用词。nltk 有一个预定义的停用词列表:
from nltk.corpus import stopwords
stop_words = stopwords.words('english')
stop_words
['i',
'me',
'my',
'myself',
'we',
'our',
'ours',
'ourselves',
'you',...
您可以使用 np.where 将停用词替换为 np.nan
title_analysis['new_col'] = np.where(title_analysis['words'].str.contains(stopwords), np.nan, title_analysis['words'])
然后做 value_counts()
title_analysis['new_col'].value_counts()
如果您有自己想要忽略的单词集,只需将 stop_words 替换为您的单词列表即可。
【讨论】: