Just wondering if there are any efficient ways to filter columns contains a list of value, e.g:
Suppose I want to filter a column contains beef, Beef:
I can do:
beefDF=df.filter(df.ingredients.contains('Beef')|df.ingredients.contains('beef'))
Instead of doing the above way, I would like to create a list:
beef_product=['Beef','beef']
and do:
beefDF=df.filter(df.ingredients.contains(beef_product))
I don't need to maintain code but just need to add new beef (e.g ox, ribeyes) in the beef_product list to have the filter dataframe.
Obviously the contains function do not take list type, what is a good way to realize this?