title: Python Dataframe calculations based on another dataframe
body: <p>I've 2 data frames.</p>
  <p><a href="https://i.stack.imgur.com/lMAtG.png" rel="nofollow noreferrer">Datraframe1</a>
  <a href="https://i.stack.imgur.com/MS6iv.png" rel="nofollow noreferrer">Dataframe2</a></p>
  <p>I'd like to populate DF1 columns with data from DF2 using below calculations.
  Prev_close column : for each (symbol, date) as key from df1, lookup (symbol,date) in df2 and get previous row &quot;CLOSE&quot; column value and populate in DF1 &quot;prev_close&quot; column.</p>
  <p>Below rest of columns are in % format.
  D1L column : for each (symbol, date) as key from df1, lookup (symbol,date) in df2 and get &quot;LOW&quot;  column value and populate in DF1 &quot;D1L&quot; column as a formula (&quot;low&quot; - &quot;prev_close&quot;) / (prev_close)</p>
  <p>D1H column : for each (symbol, date) as key from df1, lookup (symbol,date) in df2 and get &quot;HIGH&quot;  column value and populate in DF1 &quot;D1H&quot; column as a formula (&quot;high&quot; - &quot;prev_close&quot; ) / (prev_close)</p>
  <p>D2L column : for each (symbol, date) as key from df1, lookup (symbol,date) in df2 and get 2nd row after lookup row  (current row + 1) &quot;LOW&quot;  column value and populate in DF1 &quot;D2L&quot; column as a formula (&quot;low&quot; - &quot;prev_close&quot;) / (prev_close)</p>
  <p>D2H column : for each (symbol, date) as key from df1, lookup (symbol,date) in df2 and get 2nd row after lookup row (current row + 1)  &quot;HIGH&quot;  column value and populate in DF1 &quot;D2H&quot; column as a formula (&quot;high&quot; - &quot;prev_close&quot; ) / (prev_close)</p>
  <p>D3L column : for each (symbol, date) as key from df1, lookup (symbol,date) in df2 and get 3rd row after lookup row (current row + 2)   &quot;LOW&quot;  column value and populate in DF1 &quot;D3L&quot; column as a formula (&quot;low&quot; - &quot;prev_close&quot;) / (prev_close)</p>
  <p>D3H column : for each (symbol, date) as key from df1, lookup (symbol,date) in df2 and get 3rd row after lookup row (current row + 2)  &quot;HIGH&quot;  column value and populate in DF1 &quot;D3H&quot; column as a formula (&quot;high&quot; - &quot;prev_close&quot; ) / (prev_close)</p>
  <p>in the end, i'm expecting output as follows and appreciate any help or code you can provide.
  <a href="https://i.stack.imgur.com/6uAA5.png" rel="nofollow noreferrer">Expected output of Dataframe1</a></p>