title: How to filter Pandas dataframe using 'in' and 'not in' like in SQL
body: <p>How can I achieve the equivalents of SQL's <code>IN</code> and <code>NOT IN</code>?</p>
  <p>I have a list with the required values.
  Here's the scenario:</p>
  <pre><code>df = pd.DataFrame({'country': ['US', 'UK', 'Germany', 'China']})
  countries_to_keep = ['UK', 'China']
  
  # pseudo-code:
  df[df['country'] not in countries_to_keep]
  </code></pre>
  <p>My current way of doing this is as follows:</p>
  <pre><code>df = pd.DataFrame({'country': ['US', 'UK', 'Germany', 'China']})
  df2 = pd.DataFrame({'country': ['UK', 'China'], 'matched': True})
  
  # IN
  df.merge(df2, how='inner', on='country')
  
  # NOT IN
  not_in = df.merge(df2, how='left', on='country')
  not_in = not_in[pd.isnull(not_in['matched'])]
  </code></pre>
  <p>But this seems like a horrible kludge. Can anyone improve on it?</p>