title: Pandas: Using the tilde operator to return inverse data with two filters
body: <p>I'm filtering on two DataFrame columns using <code>isin</code>. Aim is to return two distinct DataFrames: One where the filter conditions are met and one where they're not. The DataFrames should be exact opposites, in effect. However I can't seem to use the tilde operator in the way I assumed I could. </p>
  
  <p>A reproducible example:</p>
  
  <pre><code>raw_data = {
      'id': ['s1', 's2', 's1', 's4', 's2', 's5', 's4', 's2'], 
      'car': ['ford', 'bmw', 'ford', 'mazda', 'ford', 'bmw', 'audi', 'bmw']}
  
  df_a = pd.DataFrame(raw_data, columns= ['id', 'car'])
  
  values1 = ['s1', 's2']
  values2 = ['bmw', 'ford']
  df_a[(df_a['id'].isin(values1)) &amp; (df_a['car'].isin(values2))]
  </code></pre>
  
  <p>Returns this:</p>
  
  <pre><code>    id  car
  0   s1  ford
  1   s2  bmw
  2   s1  ford
  4   s2  ford
  7   s2  bmw
  </code></pre>
  
  <p>Which is correct. But if try to reverse that using:</p>
  
  <p><code>df_a[~(df_a['id'].isin(values1)) &amp; (df_a['car'].isin(values2))]</code></p>
  
  <p>I get:</p>
  
  <pre><code>    id  car
  5   s5  bmw
  </code></pre>
  
  <p>Which is not the inverse. I've tried adding a second tilde to the second filter but can't make it work. Where am I going wrong, or is there a better way to do this?</p>