I have something that has been bugging me for a while.
I have a Dataframe, looking like this:
Amount Balance Date Text
90 -442.378339 5000 2018-02-12 PS Bar 04066
502 -183.229472 5000 2018-08-14 VDK EUR 39,95
957 -35.117568 5000 2019-01-28 Fakta Strandlodsve )))) 59260
1334 -15.234783 5000 2019-06-28 Rente
1867 2934.846978 5000 2019-12-09 Netbank overf�rsel
2304 -30.299886 5000 2019-05-21 MobilePay: Cathrine
2341 21.209920 5000 2019-06-03 MOBILEPAY: KRISTIAN
2357 -90.505760 5000 2019-06-04 DK-NOTA68957 NETTO GODTHÅB
2447 -182.799214 5000 2019-07-03 Forretning: REAL
2955 -121.199545 5000 2019-12-30 DK-NOTA17767 WANNASPORT.DK
I want to update the Balance column based on the Amount column.
The balance should start at 5000, but for the second row, the balance should be 5000 - 442,378339 = 4557,62, and for the third row, it should be 4557,62 - 183,229472 = 4374,39.
I have tried df['Balance'] = df['Balance'] + df['Amount'].shift(1)
The second row is correct, but after that it just keeps taking the 5000, and not the previous computed value of Balance.
df['Balance'] - df['Amount'].cumsum()ordf['Balacnce'] + df['Amount'].cumsum()