我下面有一个数据框
news score
testing tools 12
test match 32
he is testing 332
test is done 23
我想要这样的结果
news score
test match 32
test is done 23
ddf[ddf['news'].str.contains('test', regex= False)]
ddf[ddf['news'].str.contains('test', regex= False)]
答案 0 :(得分:0)
尝试一下:
pattern = '/\btest\b/'
ddf[ddf['news'].str.contains(pattern, regex= True)]
有关正则表达式模式的更多信息,请阅读: https://stackoverflow.com/a/13065780/2754195