pandas dataframe filter by column value not in list code example

Example 1: filter dataframe with list

df[df['Your_Column'].isin([3, 6])]

Example 2: pandas dataframe select rows not in list

df[~df.isin(subset).iloc[:,0]]

Example 3: pandas not in list

>>> df
  countries
0        US
1        UK
2   Germany
3     China
>>> countries
['UK', 'China']
>>> df.countries.isin(countries)
0    False
1     True
2    False
3     True
Name: countries, dtype: bool
>>> df[df.countries.isin(countries)]
  countries
1        UK
3     China
>>> df[~df.countries.isin(countries)]
  countries
0        US
2   Germany