For a Pandas dataframe with datetimes like:
DateTime
2020-6-12
2020-6-13
2020-6-14
2020-6-15
2020-6-16
2020-6-17
...
I want to group the series per 3 days and use a sliding window of 1 day. So the desired result is like:
Group
2020-6-12 2020-6-14
2020-6-13 2020-6-15
2020-6-14 2020-6-16
2020-6-15 2020-6-17
...
Grouping the data per 3 days could be achieved with:
df.groupby(pd.Grouper(key='DateTime', freq='3D'))
However, the question is how to do this with a two days overlap? I prefer to see a solution with Pandas functions, otherwise a custom/workaround solution where the same DataFrameGroupBy type is kept intact is also fine.
Thanks in advance!