title: Subtracting columns based on key column in pandas dataframe
body: <p>I have two dataframes looking like</p>
  
  <p>df1:</p>
  
  <pre><code>   ID    A   B   C   D 
  0 'ID1' 0.5 2.1 3.5 6.6
  1 'ID2' 1.2 5.5 4.3 2.2
  2 'ID1' 0.7 1.2 5.6 6.0 
  3 'ID3' 1.1 7.2 10. 3.2
  </code></pre>
  
  <p>df2:</p>
  
  <pre><code>   ID    A   B   C   D 
  0 'ID1' 1.0 2.0 3.3 4.4
  1 'ID2' 1.5 5.0 4.0 2.2
  2 'ID3' 0.6 1.2 5.9 6.2 
  3 'ID4' 1.1 7.2 8.5 3.0
  </code></pre>
  
  <p>df1 can have multiple entries with the same <code>ID</code> whereas each <code>ID</code> occurs only once in df2. Also not all <code>ID</code> in df2 are necessarily present in df1. I can't solve this by using <code>set_index()</code> as multiple rows in df1 can have the same <code>ID</code>, and that the <code>ID</code> in df1 and df2 are not aligned.</p>
  
  <p>I want to create a new dataframe where I subtract the values in <code>df2[['A','B','C','D']]</code> from <code>df1[['A','B','C','D']]</code> based on matching the ID. </p>
  
  <p>The resulting dataframe would look like:</p>
  
  <p>df_new:</p>
  
  <pre><code>   ID     A    B   C   D 
  0 'ID1' -0.5  0.1 0.2 2.2
  1 'ID2' -0.3  0.5 0.3 0.0
  2 'ID1' -0.3 -0.8 2.3 1.6
  3 'ID3'  0.5  6.0 1.5 0.2
  </code></pre>
  
  <p>I know how to do this with a loop, but since I'm dealing with huge data quantities this is not practical at all. What is the best way of approaching this with Pandas?</p>