title: Applying interpolation on DataFrame based on another DataFrame
body: <p>I have a <code>DataFrame</code> on which I would like to somehow add new columns based on the value of a specific column, whose result depends on data contained in <em>another</em> <code>DataFrame</code>.</p>
  
  <p>More specifically, I have</p>
  
  <pre><code>df_original = 
  
      Crncy  Spread  Duration
  0   EUR    100     1.2
  1   nan    nan     nan
  2          100     3.46
  3   CHF    200     2.5
  4   USD    50      5.0
  ...
  
  df_interpolation = 
  
      CRNCY  TENOR   Adj_EUR   Adj_USD
  0   EUR    1       10        20    
  1   EUR    2       20        30  
  2   EUR    5       30        40  
  3   EUR    7       40        50  
  ...
  10  CHF    1       50        10  
  11  CHF    2       60        20  
  12  CHF    5       70        30  
  ...
  </code></pre>
  
  <p>and would now like to add the columns <code>Adj_EUR</code> and <code>Adj_USD</code> to <code>df_original</code> for each row, based on the value of <code>Crncy</code> and <code>Duration</code> using standard linear interpolation.</p>
  
  <p>So, we want to use <code>TENOR</code> and <code>Adj_USD</code>/<code>Adj_EUR</code> from <code>df_interpolation</code> and <code>Duration</code> from <code>df_original</code>, for each available <code>Crncy</code>, to form the interpolation.</p>
  
  <p>E.g. Pseudo-code using <code>optimize</code>-package from <code>scipy</code>: </p>
  
  <pre><code>from scipy import optimize
  
  """ Do this for both 'Adj_EUR' and 'Adj_USD' """
  
  # For 'Adj_EUR'
  for curr, df in df_original.groupby('Crncy'):
  
      x_data = df_interpolation[df_interpolation['CRNCY']==curr].as_matrix(['TENOR'])
      y_data = df_interpolation[df_interpolation['CRNCY']==curr].as_matrix(['Adj_EUR'])
  
      """ Linear fit """
      z_linear = optimize.curve_fit(lambda t,a,b: a + b * t, x_data.ravel(), y_data.ravel())[0]
      """ Somehow add the values back to df_original in a new column """
      df['Adj_EUR'] = z_linear[0] + z_linear[1] * df['Duration']
  </code></pre>
  
  <p>Yielding</p>
  
  <pre><code>    Crncy  Spread  Duration  Adj_EUR  Adj_USD
  0   EUR    100     1.2       12       22
  1   nan    nan     nan       0.0      0.0
  ...
  </code></pre>
  
  <p>Any clue on how to do this?</p>
  
  <p>Much appreciable</p>