I have a pandas dataframe named 'df' with 4 columns: date, game_name, total_registered,newly_registered
The total registered column is a cumulative column.
Sample:
+------------+-----------+------------------+------------------+
| date | game_name | total_registered | newly_registered |
+------------+-----------+------------------+------------------+
| 2020-12-1 | abc | 10 | 4 |
| 2020-12-2 | abc | 14 | 3 |
| 2020-12-3 | abc | 0 | 5 |
| 2020-12-1 | zzz | 20 | 2 |
| 2020-12-2 | zzz | 22 | 10 |
| 2020-12-3 | zzz | 0 | 5 |
+------------+-----------+------------------+------------------+
As you can see, my cumulative column broke on the 2nd for 'abc' and on the 3rd for 'zzz'
To be safe I would like to redo my cumulative column starting on the 2nd. How can modify the current row total_registered by taking the prior day's total_registered+newly_registered values of its respective game?
Desired Output:
+------------+-----------+------------------+------------------+
| date | game_name | total_registered | newly_registered |
+------------+-----------+------------------+------------------+
| 2020-12-1 | abc | 10 | 4 |
| 2020-12-2 | abc | 14 | 3 |
| 2020-12-3 | abc | 17 | 5 |
| 2020-12-1 | zzz | 20 | 2 |
| 2020-12-2 | zzz | 22 | 10 |
| 2020-12-3 | zzz | 32 | 5 |
+------------+-----------+------------------+------------------+
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…