title: Define recursive function in Pandas dataframe
body: <p>I can't seem to find the answer to my question so I'm trying my luck on here. Would very much appreciate your help.</p>
  
  <p>I've got a Pandas dataframe with values in Col1 and Col2. Instead of the np.nan values in Col2, I'd like to calculate the following: today's Col2 value = previous day's Col2 value multiplied by today's Col1 value. </p>
  
  <p>This should be some form of recursive function. I've tried several answers, including a for loop here below, but none seem to work:</p>
  
  <pre><code>df = pd.read_excel('/Users/fhggshgf/Desktop/test.xlsx')
  df.index = df.date
  df.drop(['date'], axis=1, inplace=True)
  
  for i in range(1, len(df)):
      fill_value = df['Col2'].iloc[i - 1]
      finaldf['Col2'].fillna(fill_value, inplace=True)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/YW3oI.png" rel="nofollow noreferrer">screenshot</a></p>