BUG/ENH: groupby with a list of customgroup and string should work · Issue #3794 · pandas-dev/pandas (original) (raw)

import datetime as DT

df = pd.DataFrame({
'Branch' : 'A A A A A B'.split(),
'Buyer': 'Carl Mark Carl Joe Joe Carl'.split(),
'Quantity': [1,3,5,8,9,3],
'Date' : [
DT.datetime(2013,1,1,13,0),
DT.datetime(2013,1,1,13,5),
DT.datetime(2013,10,1,20,0),
DT.datetime(2013,10,2,10,0),
DT.datetime(2013,12,2,12,0),                                      
DT.datetime(2013,12,2,14,0),
]})

df = df.set_index('Date', drop=False)
df.groupby([TimeGrouper('6M'),'Buyer']).sum()