I am trying to create a new columns of percentages which is a product of value in a row above and the value in the same row of another column. I have tried using shift and loc with no luck.
I have tried using:
df.at[0,'new_col'] = df.at[0,'other_col']
This first part works well and then
df['new_col'] = df['new_col'].shift(1)*df['other_col']
this however does not work.
My data example is as follows:
time | val | adj_val |
---|---|---|
0 | 1 | 1 |
1 | 0.5 | 0.5 |
2 | 0.6 | 0.3 |
3 | 0.7 | 0.21 |
4 | 0.9 | 0.189 |
I have been trying to work around this for a well such as using df.loc but with no exercise.