Pandas:选择与字符串匹配的行,并使用该单词创建新列 我想创建一个新列选择与字符串匹配的行,并使用该单词创建一个新列(找到)
list_provided=["mul","the","have", "then"]
我的数据框外观
id text
a simultaneous there the
b simultaneous there
c mul why
预期产量
id text found
1 simultaneous there the the
2 simultaneous there
3 mul why mul
4 have the have, the
5 then the late then,the
答案 0 :(得分:2)
我认为类似这样的方法应该起作用:
df['text'].apply(lambda x: [i for i in x.split() if i in list_provided])