从文件中删除停用词

Dat*_*ewB 5 python csv pandas

我想从我的文件中的数据列中删除停用词.我过滤了最终用户说话时的界限.但它并没有过滤掉usertext.apply(lambda x: [word for word in x if word not in stop_words]) 我做错了什么的停顿词?

import pandas as pd
from stop_words  import get_stop_words
df = pd.read_csv("F:/textclustering/data/cleandata.csv", encoding="iso-8859-1")
usertext = df[df.Role.str.contains("End-user",na=False)][['Data','chatid']]
stop_words = get_stop_words('dutch')
clean = usertext.apply(lambda x: [word for word in x if word not in stop_words])
print(clean)
Run Code Online (Sandbox Code Playgroud)

gal*_*yan 0

clean = usertext.apply(lambda x:  x if x not in stop_words else '')
Run Code Online (Sandbox Code Playgroud)