title: Subtracting dataframes with unequal numbers of rows
body: <p>I have two dataframes like this </p>
  
  <pre><code>import pandas as pd
  import numpy as np
  
  np.random.seed(0)
  
  df1 = pd.DataFrame(np.random.randint(10, size=(5, 4)), index=list('ABCDE'), columns=list('abcd'))
  df2 = pd.DataFrame(np.random.randint(10, size=(2, 4)), index=list('CE'), columns=list('abcd'))
  
     a  b  c  d
  A  5  0  3  3
  B  7  9  3  5
  C  2  4  7  6
  D  8  8  1  6
  E  7  7  8  1
  
     a  b  c  d
  C  5  9  8  9
  E  4  3  0  3
  </code></pre>
  
  <p>The index of <code>df2</code> is always a subset of the index of <code>df1</code> and the column names are identical.</p>
  
  <p>I want to create a third dataframe <code>df3 = df1 - df2</code>. If one does that, one obtains</p>
  
  <pre><code>     a    b    c    d
  A  NaN  NaN  NaN  NaN
  B  NaN  NaN  NaN  NaN
  C -3.0 -5.0 -1.0 -3.0
  D  NaN  NaN  NaN  NaN
  E  3.0  4.0  8.0 -2.0
  </code></pre>
  
  <p>I don't want the <code>NAs</code> in the ouput but the respective values of <code>df1</code>. Is there a smart way of using e.g. <code>fillna</code> with the values of <code>df1</code> in the rows not contained in <code>df2</code>?</p>
  
  <p>A workaround would be to do the subtract only the required rows like:</p>
  
  <pre><code>sub_ind = df2.index
  df3 = df1.copy()
  df3.loc[sub_ind, :] = df1.loc[sub_ind, :] - df2.loc[sub_ind, :]
  </code></pre>
  
  <p>which gives me the desired output</p>
  
  <pre><code>   a  b  c  d
  A  5  0  3  3
  B  7  9  3  5
  C -3 -5 -1 -3
  D  8  8  1  6
  E  3  4  8 -2
  </code></pre>
  
  <p>but maybe there is a more straightforward way of achieving this?</p>