Problem
How to create column that resamples 5 minutes in pandas but only till current certain row, so either last 5 minutes from current observation, or 5 minutes interval but if I am at minute 3 to resample last 5 or last 3, point being not to resample by future. DataFrame is ordered by datetime
for example first rows can be disregarded since 5 mins did not accumulate yet:
Desired output
datetime result mean
3/1/2022 0:04 1
3/1/2022 0:05 0
3/1/2022 0:06 0
3/1/2022 0:06 1
3/1/2022 0:07 1
3/1/2022 0:08 1
3/1/2022 0:10 1 0.666666667
3/1/2022 0:11 1 0.833333333
3/1/2022 0:12 0 0.8
3/1/2022 0:13 0 0.666666667
3/1/2022 0:14 0 0.4
3/1/2022 0:17 0 0
3/1/2022 0:18 1 0.25
3/1/2022 0:19 1 0.5
3/1/2022 0:20 1 0.75
3/1/2022 0:21 1 0.8
3/1/2022 0:22 1 0.833333333
3/1/2022 0:23 1 1