假设我有这个包含四行的数据框表:
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包含,但它会根据查询返回确切的行(“问题很困难”)。任何帮助表示赞赏。
尝试:
df[df['Text'].str.contains('is|issue')