1>>> df
2 countries
30 US
41 UK
52 Germany
63 China
7>>> countries
8['UK', 'China']
9>>> df.countries.isin(countries)
100 False
111 True
122 False
133 True
14Name: countries, dtype: bool
15>>> df[df.countries.isin(countries)]
16 countries
171 UK
183 China
19>>> df[~df.countries.isin(countries)]
20 countries
210 US
222 Germany
1# Filter dataframe by multiple values in a column or multiple columns
2# SQL equivalent: WHERE columnA IN ('val1', 'val2') AND columnB > 70
3
4df[ (df.columnA.isin(['val1', 'val2'])) & (df['columnB'] > 70) ]