以任意顺序检索包含多个文本查询的 Pandas 行
Retrieve Pandas Rows which Contain Multiple Text Query in Any Order
假设我有这个数据框 table 四行:
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
所有三行都包含 "is" 或 "issue",顺序不限。因此,您也可以在函数中写入 somefunction('is', 'issue') 因为确切的位置并不重要。我尝试使用 Pandas 包含但它 returns 根据查询 ('the issue is difficult') 的确切行。任何帮助表示赞赏。
尝试:
df[df['Text'].str.contains('is|issue')
假设我有这个数据框 table 四行:
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
所有三行都包含 "is" 或 "issue",顺序不限。因此,您也可以在函数中写入 somefunction('is', 'issue') 因为确切的位置并不重要。我尝试使用 Pandas 包含但它 returns 根据查询 ('the issue is difficult') 的确切行。任何帮助表示赞赏。
尝试:
df[df['Text'].str.contains('is|issue')