I have a data frame given below
news score
testing tools 12
test match 32
he is testing 332
test is done 23
I want a result like this
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)]
Try this:
pattern = '/\btest\b/'
ddf[ddf['news'].str.contains(pattern, regex= True)]
For more information about regex pattern read this: https://stackoverflow.com/a/13065780/2754195
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.