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.
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.
This should be some form of recursive function. I've tried several answers, including a for loop here below, but none seem to work:
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)
previous day's Col2 value multiplied by today's Col1 value, but your codes don't show any multiplication. It is really a multiplication? could you add the expected output?