0

I have a data table that contains several keywords in one column and I would like to filter if one of the keywords registers with my query.

Assume this example DataFrame:

    import pandas as pd 
    testdata = pd.DataFrame({"key":["This is", "just a", "meaningless and boring test example"], "value" : [2,3,4]})

This should result in a DataFrame like this:

key                                 | value
--------------------------------------------
This is                             | 2
just a                              | 3
meaningless and boring text example | 4

I'd now like to filter for occurrence if some keywords are part of my keywords. i. e. show all rows that contain "This" and "meaningless". In code I would expect something to work like:

    testdata.query('key in ["This", "meaningless"]')
MichaelA
  • 1,432
  • 2
  • 15
  • 32

0 Answers0