【发布时间】:2023-03-29 00:24:01
【问题描述】:
我有包含 41,000 行 Flickr 标签的多列数据框。我只想从一列中删除所有英文停用词,而其他列保持不变。
这是我从 nltk.corpus 中提取停用词列表的代码:
from nltk.corpus import stopwords
stopWordsListEng = stopwords.words("english")
但我想添加我能想到的其他停用词:
according accordingly across act actually
我还没有弄清楚如何将其添加到现有的停用词列表中。
以及如何应用 lambda 仅删除一列中的停用词。因为我希望我的代码尽可能简单。
这是我的专栏的样子:
column1 column2 column3
some words from this column i don't know actually what across to me accordingly 25,000
我希望我的专栏在删除所有停用词后看起来像这样(或多或少):
column1 column2 column3
some words from this column don't know what to me 25,000
【问题讨论】:
-
您好,欢迎来到 StackOverflow!你使用的是什么版本的 Python 和 NLTK?我建议将
stopWordsListEng转换为set并将单词添加到集合中。 -
嗨@hongsy,我使用python 3.7.3,但我不知道如何检查我使用的NLTK版本
标签: python lambda tags flickr stop-words