检索以任意顺序包含多个文本查询的熊猫行

问题描述 投票:0回答:1

假设我有这个包含四行的数据框表:

Text
-----
there is an issue
very enormous issue
the issue is difficult
you think

Pandas中是否有任何方法可以检索包含“ issue”或“ is”的顺序或映射功能的行?因此,结果应如下所示:

df[df['Text'].somefunction('issue, is')

Text
-----
there is an issue
very enormous issue
the issue is difficult

所有三行都以任意顺序包含“是”或“问题”。因此,您也可以在函数中写入somefunction('is','issue'),因为确切的位置无关紧要。我尝试使用Pandas包含,但它会根据查询返回确切的行(“问题很困难”)。任何帮助表示赞赏。

pandas dataframe mapping contains
1个回答
1
投票

尝试:

df[df['Text'].str.contains('is|issue')
© www.soinside.com 2019 - 2024. All rights reserved.