【发布时间】:2020-08-14 09:42:54
【问题描述】:
我在数据框列中存储了一个字符串
import pandas as pd
df = pd.DataFrame({"ID": 1, "content": "froyay-xcd = (E)-cut-2-froyay-xcd"}, index=[0])
print(df)
idx = df[df['content'].str.contains("froyay-xcd = (E)-cut-2-froyay-xcd")]
print(idx)
我正在尝试查找包含搜索字符串的行的索引,并出现以下警告
UserWarning: This pattern has match groups. To actually get the groups, use str.extract.
return func(self, *args, **kwargs)
我不确定为什么当搜索字符串实际存在于数据框列中时会返回一个空数据框。
任何建议都将受到高度赞赏。我希望输出返回存储在数据框中的行。
【问题讨论】:
标签: python-3.x pandas string dataframe