I got the following dataframe containing daily data and I would like to resample it to weekly data.
Name Target Sales
Datetime
2021-12-01 Amy 1000 26000
2021-12-02 Amy 1000 0
...
2021-12-30 Amy 1000 0
2021-12-31 Amy 1000 0
2021-12-01 Zoe 1000 1680
2021-12-02 Zoe 1000 0
...
2021-12-30 Zoe 1000 19414
2021-12-31 Zoe 1000 0
I performed the following code, however, the result does not satisfy my need.
sum_dict = {'Target':'sum','Sales':'sum'}
df.groupby(['Name']).resample('W').apply(sum_dict )
And the result where the last index becomes Jan
instead of Dec
Name Target Sales
Datetime
2021-12-05 Amy 5000 35100
2021-12-12 Amy 7000 -8403.6
2021-12-19 Amy 7000 179176
2021-12-26 Amy 7000 50222
2022-01-02 Amy 5000 0
2021-12-05 Zoe 5000 1680
2021-12-12 Zoe 7000 57415
2021-12-19 Zoe 7000 80254
2021-12-26 Zoe 7000 75256.4
2022-01-02 Zoe 5000 43494
What I expect is the following:
Name Target Sales
Datetime
2021-12-05 Amy 5000 35100
2021-12-12 Amy 7000 -8403.6
2021-12-19 Amy 7000 179176
2021-12-26 Amy 7000 50222
2021-12-31 Amy 5000 0
2021-12-05 Zoe 5000 1680
2021-12-12 Zoe 7000 57415
2021-12-19 Zoe 7000 80254
2021-12-26 Zoe 7000 75256.4
2021-12-31 Zoe 5000 43494
The end date is using the end date of that month instead of the last date of that week. Thanks!