How do I upsample a dataframe using resample() to get the initial values divided over the new sample frequency?
Dataframe with monthly sample frequency
date revenue
0 2021-11-01 00:00:00+00:00 300
1 2021-10-01 00:00:00+00:00 500
2 2021-09-01 00:00:00+00:00 100
3 2021-08-01 00:00:00+00:00 50
4 2021-07-01 00:00:00+00:00 200
5 2021-06-01 00:00:00+00:00 150
Approximate expected Dataframe with revenue divided over the days in that month
revenue
date
2021-06-01 00:00:00+00:00 4.8
2021-06-02 00:00:00+00:00 4.8
2021-06-03 00:00:00+00:00 4.8
2021-06-04 00:00:00+00:00 4.8
2021-06-05 00:00:00+00:00 4.8
... ...
2021-11-28 00:00:00+00:00 9.6
2021-11-29 00:00:00+00:00 9.6
2021-11-30 00:00:00+00:00 9.6
2021-11-31 00:00:00+00:00 9.6
ie, i want to be sure that the values get divided over the amount of days in that sepcific month
You can use
asfreqto convert the timeseries from monthly to daily frequency, then useffillto forward fill the values then divide therevenuebydaysinmonthattribute ofdatetimeindexto calculate distributed revenue