【发布时间】:2018-05-17 11:55:45
【问题描述】:
我在大型数据帧上使用 str.contains,我需要一种方法,以便 str.contains 返回我的 str.contains 函数为 True 的记录。 (数据框有几千行长,我正在寻找 8 个真实响应)。
谢谢!
aa = filtered_to_df.body.str.contains('AA')
aa.head(10)
Out[312]:
15864 False
18040 False
22576 False
28092 False
32800 False
33236 False
38027 False
41222 False
46647 False
87645 False
Name: body, dtype: bool
【问题讨论】:
-
显示您的数据主管
-
你是如何使用 str.contains 的?
-
已添加 - 我在想有没有办法在系列中使用 loc?
-
我刚刚加了:aa = filters_to_df.body.str.contains('AA')
-
如果你想否定使用波浪号
~,比如~aa或aa = ~filtered.....
标签: python string pandas contain