我有一系列文字文章(df ['posttext'])。该系列的每一行都是字符串。我想知道哪些包含问号。
当我尝试
df['posttext'].str.contains("?")
我明白了:
error: nothing to repeat at position 0.
答案 0 :(得分:3)
此contains
方法需要一个正则表达式。 You can turn that off通过提供名为regex
的关键字参数:
df['posttext'].str.contains("?", regex=False)
答案 1 :(得分:0)
您可以转义问号,以强制其查找文字字符
df['posttext'].str.contains("\?")