I'm trying to calculate the cumulative total for the next 4 weeks.
Here is an example of my data frame
d = {'account': [10, 10, 10, 10, 10, 10, 10, 10],
'volume': [25, 60, 40, 100, 50, 100, 40, 50]}
df = pd.DataFrame(d)
df['week_starting'] = pd.date_range('05/02/2021',
periods=8,
freq='W')
df['volume_next_4_weeks'] = [225, 250, 290, 290, 240, 190, 90, 50]
df['volume_next_4_weeks_cumulative'] = ['(25+60+40+100)', '(60+40+100+50)', '(40+100+50+100)', '(100+50+100+40)', '(50+100+40+50)', '(100+40+50)', '(40+50)', '(50)']
df.head(10)
I would to find a way to calculate the cumulative amount by pd.Grouper freq = 4W.