title: How to do left outer join exclusion in pandas
body: <p>I have two dataframes, A and B, and I want to get those in A but not in B, just like the one right below the top left corner.</p>
  
  <p><a href="https://i.stack.imgur.com/pxUO3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pxUO3.png" alt="The one below the top left"></a></p>
  
  <p>Dataframe A has columns <code>['a','b' + others]</code> and B has columns <code>['a','b' + others]</code>. There are no NaN values. I tried the following:</p>
  
  <p>1.</p>
  
  <pre><code>dfm = dfA.merge(dfB, on=['a','b'])
  dfe = dfA[(~dfA['a'].isin(dfm['a']) | (~dfA['b'].isin(dfm['b'])
  </code></pre>
  
  <p>2.</p>
  
  <pre><code>dfm = dfA.merge(dfB, on=['a','b'])
  dfe = dfA[(~dfA['a'].isin(dfm['a']) &amp; (~dfA['b'].isin(dfm['b'])
  </code></pre>
  
  <p>3.</p>
  
  <pre><code>dfe = dfA[(~dfA['a'].isin(dfB['a']) | (~dfA['b'].isin(dfB['b'])
  </code></pre>
  
  <p>4.</p>
  
  <pre><code>dfe = dfA[(~dfA['a'].isin(dfB['a']) &amp; (~dfA['b'].isin(dfB['b'])
  </code></pre>
  
  <p>but when I get <code>len(dfm)</code> and <code>len(dfe)</code>, they don't sum up to <code>dfA</code> (it's off by a few numbers). I've tried doing this on dummy cases and #1 works, so maybe my dataset may have some peculiarities I am unable to reproduce.</p>
  
  <p>What's the right way to do this?</p>