I try to convert monthly time series data quarterly, and then summarize the amounts for the quarter. I get KeyError: 'date' when I run the following.
abc= abc.set_index('date').to_period('Q').groupby(['origin',
'date']).agg(sum)
However, when I reset the index as shown below, the code works. Why do I need to reset the index to use groupby in the origin and date fields? Is there a way to group without resetting the index?
abc= abc.set_index('date').to_period('Q').reset_index().groupby(['origin',
'date']).agg(sum)
source
share