【发布时间】:2021-01-17 09:17:53
【问题描述】:
我还有一个关键字/句子列表。我想将它与“内容”列匹配,看看是否有任何关键字或句子匹配。
# instructions_list is just the list of keywords and key sentences
instructions_list = instructions['Key words & sentence search'].tolist()
pattern = '|'.join(instructions_list)
bureau_de_sante[bureau_de_sante['Content'].str.contains(pattern, regex = True)]
虽然它给了我结果,但它也给了我这个 UserWarning : UserWarning: This pattern has match groups。要实际获取组,请使用 str.extract。 返回 func(self, *args, **kwargs)。
问题:
- 如何防止显示用户警告?
- 找到并查看列中是否存在匹配项后,如何在新列中打印特定匹配项?
【问题讨论】:
-
可以分享一下 1)pandas的版本;和 2) 指令列表?如果您的说明中有括号,则说明“匹配组”
-
@qmeeus 我已经更新了