title: Pandas for recursive data
body: <p><a href="https://i.stack.imgur.com/LQNf6.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>How do i create a dataframe which first cell has a different pandas formula from the subsequent cells?</p>
  
  <p>From the above, The first cell of the Ave Gain is simply the average of the first 2 gains: (1.84 + 0) / 2 = 0.92. Similarly for  first cell of the Ave  Loss : (0.07 + 0) / 2 = 0.035</p>
  
  <p>However the second cell of the Ave Gain is the previous Ave Gain (0.92) + the new Gain (1.62) divided by 2 : (0.92+1.62) /2 = 1.27</p>
  
  <p>and the third cell is the previous Ave Gain (1.27) + the new gain (1.61) divided by 2: = (1.27+1.61) / 2 = 1.44</p>
  
  <p>1)How should i go about creating a dataframe which first cell has a different formula from the subsequent cells?</p>
  
  <p>2)How do i create a recursive table for the Ave Gain (it uses its own previous value to calculate the next value)</p>
  
  <p>Thank you</p>