Python 将自定义停止字附加到nltk.corpus中的默认停止字列表中,并使用lambda从数据帧中的序列中删除停止字
我有41000行Flickr标记的多列数据帧。我只想删除一列中的所有英文stopwords,其他列保持不变 这是我从nltk.corpus中提取停止词列表的代码:Python 将自定义停止字附加到nltk.corpus中的默认停止字列表中,并使用lambda从数据帧中的序列中删除停止字,python,lambda,tags,flickr,stop-words,Python,Lambda,Tags,Flickr,Stop Words,我有41000行Flickr标记的多列数据帧。我只想删除一列中的所有英文stopwords,其他列保持不变 这是我从nltk.corpus中提取停止词列表的代码: from nltk.corpus import stopwords stopWordsListEng = stopwords.words("english") 但我想补充一些我能想到的词: according accordingly across act actually 我还没有弄清楚如何将其添加到现有的stopwords列表中
from nltk.corpus import stopwords
stopWordsListEng = stopwords.words("english")
但我想补充一些我能想到的词:
according accordingly across act actually
我还没有弄清楚如何将其添加到现有的stopwords列表中
以及如何应用lambda仅删除一列中的停止字。因为我希望我的代码尽可能简单
我的专栏是这样的:
column1 column2 column3
some words from this column i don't know actually what across to me accordingly 25,000
我希望在删除所有stopwords后,我的专栏看起来像这样(或多或少):
column1 column2 column3
some words from this column don't know what to me 25,000
您可以使用list
extend
_new_stopwords_to_add = ['according', 'accordingly', 'across', 'act', 'actually']
stopWordsListEng.extend(_new_stopwords_to_add)
仅使用从一列中删除停止字
您可以使用list
extend
_new_stopwords_to_add = ['according', 'accordingly', 'across', 'act', 'actually']
stopWordsListEng.extend(_new_stopwords_to_add)
仅使用从一列中删除停止字
我该怎么做@Shijith?明白了@shijithh我该怎么做@Shijith?明白了@ShijithHi欢迎来到StackOverflow!您使用的是什么版本的Python和NLTK?我建议将
stopWordsListEng
转换为set
并将单词添加到set中。嗨@hongsy,我使用的是python 3.7.3,我不知道如何检查我使用的NLTK版本嗨,欢迎使用StackOverflow!您使用的是什么版本的Python和NLTK?我建议将stopWordsListEng
转换为set
并将单词添加到set中。嗨@hongsy,我使用的是python 3.7.3,我不知道如何检查我使用的NLTK版本