Let's take the following DataFrame:
df = pd.DataFrame({
'Buyer': 'Carl Mark Joe John Joe Mark Carl'.split(),
'Quantity': [1,3,5,8,9,3,3],
'Date' : [
DT.datetime(2013,9,1,13,0),
DT.datetime(2013,9,1,13,5),
DT.datetime(2013,10,1,20,0),
DT.datetime(2013,10,3,10,0),
DT.datetime(2013,12,2,12,0),
DT.datetime(2013,12,2,14,0),
DT.datetime(2013,12,2,14,0)
]})
df.set_index('Date', inplace=True)
With that I would like to use a weekly grouping using:
df.groupby(TimeGrouper('1W')).apply(mytest)
is there any possibility to get the corresponding week anyhow in the mytest function. I am asking because I need to query in the mytest function another DataFrame which has the same week index as the one which is derived through the applied weekly grouping.
Any help is appreciated