小编Aim*_*mee的帖子

python如果多个字符串返回句子中包含的单词

我有一个单词列表,如果声明,我想做,下面是我的列表:

list = ['camera','display','price','memory'(will have 200+ words in the list)]
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

def check_it(sentences):
    if 'camera' in sentences and 'display' in sentences and 'price' in sentences:
        return "Camera/Display/Price"
    if 'camera' in sentences and 'display' in sentences:
        return "Camera/Display"
    ...
    return "Others"

h.loc[:, 'Category'] = h.Mention.apply(check_it)
Run Code Online (Sandbox Code Playgroud)

对于这些组合将有太多组合,并且我希望单独返回行.有谁知道如何制作这个样本并单独返回单词而不是做'相机/显示/价格'?

python combinations matching pandas

2
推荐指数
1
解决办法
129
查看次数

标签 统计

combinations ×1

matching ×1

pandas ×1

python ×1