0

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)]
Alderven
  • 6,120
  • 4
  • 22
  • 35

1 Answers1

0

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

Mehdi
  • 1,120
  • 1
  • 13
  • 33