Simultaneous operation of groupby and resample on pandas dataframe?
Update Pandas 0.21 answer: pd.TimeGrouper is getting deprecated, use pd.Grouper instead.
mean_agg = (df.groupby(['JOB_TITLE',pd.Grouper(freq='5AS')])['BASE_SALARY']
.mean())
mean_agg.unstack('JOB_TITLE')
Instead of using resample, let's try to use pd.TimeGrouper
mean_agg = (df
.groupby(['JOB_TITLE',pd.TimeGrouper(freq='5AS')])['BASE_SALARY']
.mean())
mean_agg.unstack('JOB_TITLE')
TimeGrouper aligns the bins of the grouped time range.