pbpython icon indicating copy to clipboard operation
pbpython copied to clipboard

Slightly idiosyncratic usage of groupby

Open dhirschfeld opened this issue 5 years ago • 2 comments

When grouping by month in the notebook below you use a pd.Grouper object: https://github.com/chris1610/pbpython/blob/d170f4475720ca8f5fdc6770214b8f90f2197f75/notebooks/pandas-styling.ipynb#L733-L735

..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

dhirschfeld avatar Jun 03 '19 00:06 dhirschfeld

Thanks for the feedback. It's a good point.

I'll update the notebook and article shortly.

Thank you for the feedback.

chris1610 avatar Jun 03 '19 13:06 chris1610

It's a great article! I'm planning on sharing it with my users, most of whom are just learning Python.

dhirschfeld avatar Jun 03 '19 19:06 dhirschfeld