Suppose I have a dataframe df as:
df = pd.DataFrame({'Index': [1, 2, 3, 4, 5],
'Name': ['A', 'B', 100, 'C', 'D'],
'col1': [np.nan, 'bbby', 'cccy', 'dddy', 'EEEEE'],
'col2': ['water', np.nan, 'WATER', 'soil', 'cold air'],
'col3': ['watermelone', 'hot AIR', 'air conditioner', 'drink', 50000],
'Results': [1000, 2000, 3000, 4000, 5000]})
Out
Index Name col1 col2 col3 Results
1 A NaN water watermelone 1000
2 B bbbY NaN hot AIR 2000
3 100 cccY water air conditioner 3000
4 C dddf soil drink 4000
5 D EEEEE cold air 50000 5000
I have a list: matches = ['wat','air']
How can I choose all rows with col1 or col2 or col3 containing i in matches.
Expected output:
Index Name col1 col2 col3 Results
1 A NaN water watermelone 1000
2 B bbbY NaN hot AIR 2000
3 100 cccY water air conditioner 3000
5 D EEEEE cold air 50000 5000