Pandas: filter a column containing a list with df.query()
Dataframe.query() of the library Pandas allows you to filter a dataframe with a textual query (string). Personally, I like the readability that this brings and it is easy to use with booleans.
query(), the results are then returned to the page.
I noticed that beyond about thirty filters, errors were frequent. The trick is then to use equality with a list, which scales much better!
# not good df.query(' (column_a == "val1") | (column_a == "val2" ) | ...', inplace=True) # better! df.query(' column_a == ["val1", "val2", ...]', inplace=True)