-
-
Notifications
You must be signed in to change notification settings - Fork 980
Open
Description
When grouping by month in the notebook below you use a pd.Grouper object:
pbpython/notebooks/pandas-styling.ipynb
Lines 733 to 735 in d170f44
| "monthly_sales = df.groupby([pd.Grouper(key='date', freq='M')])['ext price'].agg(['sum']).reset_index()\n", | |
| "monthly_sales['pct_of_total'] = monthly_sales['sum'] / df['ext price'].sum()\n", | |
| "monthly_sales" |
..whereas the same could be accomplished by simply using the resample method:
monthly_sales = df.resample('MS', on='date')['ext price'].agg(['sum'])Whilst I think it's useful for power users to know they can construct Grouper objects themselves I think for less advanced users it's an internal implementation detail which they don't really need to know and which makes it seem more complicated than it needs to be
Metadata
Metadata
Assignees
Labels
No labels