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
  • 7,569
  • 5
  • 26
  • 38

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,260
  • 2
  • 16
  • 36