Lets say I have a dataframe where I have banking information. I have present value, a list of transactions, and I want to work backwards to calculate the balance over time.
Here is the dataframe:
value CN_running_balance
2020-08-07 -50.82 843.70
2020-08-06 893.77 NaN
2020-08-05 0.00 NaN
2020-08-04 -9.56 NaN
2020-08-03 -12.21 NaN
... ... ...
2020-05-14 1224.78 NaN
2020-05-13 0.00 NaN
2020-05-12 0.00 NaN
2020-05-11 -25.00 NaN
2020-05-10 -0.00 NaN
And I want to transform the running balance to use that rows value column for next row, by subtracting the value from the balance.
value CN_running_balance
2020-08-07 -50.82 843.70
2020-08-06 893.77 894.52
2020-08-05 0.00 0.75
2020-08-04 -9.56 etc
2020-08-03 -12.21 etc
... ... ...
2020-05-14 1224.78 etc
2020-05-13 0.00 etc
2020-05-12 0.00 etc
2020-05-11 -25.00 etc
2020-05-10 -0.00 etc
This has been pretty tricky for me so I would appreciate any suggestions on how to solve the problem!