title: Pandas: take the minimum of two operations on two dataframes, while preserving index
body: <p>I'm a beginner with Pandas. I've got two dataframes df1 and df2 of three columns each, labelled by some index.</p>
  <p>I would like to get a third dataframe whose entries are
  min( df1-df2, 1-df1-df2 )
  for each column, while preserving the index.</p>
  <p>I don't know how to do this on all the three columns at once. If I try e.g. <code>np.min( df1-df2, 1-df1-df2 )</code> I get <code>TypeError: 'DataFrame' objects are mutable, thus they cannot be hashed</code>, whereas <code>min( df1-df2, 1-df1+df2 )</code> gives <code>ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().</code></p>
  <p>I can't use <code>apply</code> because I've got more than one dataframe. Basically, I would like to use something like <code>subtract</code>, but with the ability to define my own function.</p>
  <p>Example: consider these two dataframes
  <code>df0 = pd.DataFrame( [[0.1,0.2,0.3], [0.3, 0.1, 0.2], [0.1, 0.3, 0.9]], index=[2,1,3], columns=['px', 'py', 'pz'] )</code></p>
  <pre><code>In [4]: df0
  Out[4]: 
      px   py   pz
  2  0.1  0.2  0.3
  1  0.3  0.1  0.2
  3  0.1  0.3  0.9
  </code></pre>
  <p>and</p>
  <p><code>df1 = pd.DataFrame( [[0.9,0.1,0.9], [0.1,0.2,0.1], [0.3,0.1,0.8]], index=[3,1,2], columns=['px', 'py', 'pz'])</code></p>
  <pre><code>    px   py   pz
  3  0.9  0.1  0.9
  1  0.1  0.2  0.1
  2  0.3  0.1  0.8
  </code></pre>
  <p>my desired output is a new dataframe df, made up of three columns 'px', 'py', 'pz', whose entries are:</p>
  <pre><code>   for j in range(1,4):
         dfx[j-1] = min( df0['px'][j] - df1['px'][j], 1 - df0['px'][j] + df1['px'][j] )
  </code></pre>
  <p>for df['px'], and similarly for 'py' and 'pz'.</p>
  <pre><code>    px   py   pz
  1  0.2 -0.1  0.1
  2 -0.2  0.1 -0.5
  3 -0.8  0.2  0.0
  </code></pre>
  <p>I hope it's clear now! Thanks in advance!</p>