title: How to subtract one dataframe from another?
body: <p>First, let me set the stage.</p>
  
  <p>I start with a <code>pandas</code> dataframe <code>klmn</code>, that looks like this:</p>
  
  <pre><code>In [15]: klmn
  Out[15]: 
      K  L         M   N
  0   0  a -1.374201  35
  1   0  b  1.415697  29
  2   0  a  0.233841  18
  3   0  b  1.550599  30
  4   0  a -0.178370  63
  5   0  b -1.235956  42
  6   0  a  0.088046   2
  7   0  b  0.074238  84
  8   1  a  0.469924  44
  9   1  b  1.231064  68
  10  2  a -0.979462  73
  11  2  b  0.322454  97
  </code></pre>
  
  <p>Next I split <code>klmn</code> into two dataframes, <code>klmn0</code> and <code>klmn1</code>, according to the value in the 'K' column:</p>
  
  <pre><code>In [16]: k0 = klmn.groupby(klmn['K'] == 0)
  In [17]: klmn0, klmn1 = [klmn.ix[k0.indices[tf]] for tf in (True, False)]
  In [18]: klmn0, klmn1
  Out[18]: 
  (   K  L         M   N
  0  0  a -1.374201  35
  1  0  b  1.415697  29
  2  0  a  0.233841  18
  3  0  b  1.550599  30
  4  0  a -0.178370  63
  5  0  b -1.235956  42
  6  0  a  0.088046   2
  7  0  b  0.074238  84,
       K  L         M   N
  8   1  a  0.469924  44
  9   1  b  1.231064  68
  10  2  a -0.979462  73
  11  2  b  0.322454  97)
  </code></pre>
  
  <p>Finally, I compute the mean of the <code>M</code> column in <code>klmn0</code>, grouped by the value in the <code>L</code> column:</p>
  
  <pre><code>In [19]: m0 = klmn0.groupby('L')['M'].mean(); m0
  Out[19]: 
  L
  a   -0.307671
  b    0.451144
  Name: M
  </code></pre>
  
  <p>Now, my question is, <strong><em>how can I subtract <code>m0</code> from the <code>M</code> column of the <code>klmn1</code> sub-dataframe, respecting the value in the <code>L</code> column?</em></strong>  (By this I mean that <code>m0['a']</code> gets subtracted from the <code>M</code> column of each row in <code>klmn1</code> that has <code>'a'</code> in the <code>L</code> column, and likewise for <code>m0['b']</code>.)</p>
  
  <p>One could imagine doing this in a way that replaces the the values in the <code>M</code> column of <code>klmn1</code> with the new values (after subtracting the value from <code>m0</code>).  Alternatively, one could imagine doing this in a way that leaves <code>klmn1</code> unchanged, and instead produces a new dataframe <code>klmn11</code> with an updated <code>M</code> column.  <em>I'm interested in both approaches.</em></p>