Hi all

I couldn't find a good answer to this on StackOverflow, but I was trying to understand what the conceptual difference were between GroupBy, DataFrameGroupby, and SeriesGroupBy were given that they are mentioned separately in the pandas documentation. I looked through the source code and it looks like GroupBy has an overlap of methods that can be used for both Dataframes and Series objects? However, it seems like most SeriesGroupBy methods are only for Series objects. Likewise, DataframeGroupBy methods are only for Dataframe objects. There seems to be some overlap with GroupBy and DataframeGroupBy methods, but not with SeriesGroupBy, which is why I'm a little confused.

Thanks!

Comment From: jbrockmendel

GroupBy is the parent class for SeriesGroupBy and DataFrameGroupBy. Series.groupby(...) returns a SeriesGroupBy object. DataFrame.groupby(...) returns a DataFrameGroupBy object. I don't think there's any way to get just a GroupBy object.

Places in the docs that refer to GroupBy are probably using that as a shorthand for "SeriesGroupBy and/or DataFrameGroupBy". Would welcome a PR to clarify that where relevant.

Comment From: pyrito

@jbrockmendel that's what I figured for most of the methods. Sometimes I see methods like: https://pandas.pydata.org/docs/reference/api/pandas.core.groupby.GroupBy.all.html and https://pandas.pydata.org/docs/reference/api/pandas.core.groupby.DataFrameGroupBy.all.html and get confused because there isn't one for SeriesGroupBy. Can I assume that GroupBy can be applied to both DataFrame and Series?

Comment From: jbrockmendel

Yes

Comment From: rhshadrach

I was trying to understand what the conceptual difference were between GroupBy, DataFrameGroupby, and SeriesGroupBy were given that they are mentioned separately in the pandas documentation

Are you looking at the dev docs? This has been overhauled and will be updated in 2.0:

https://pandas.pydata.org/pandas-docs/dev/reference/groupby.html

Comment From: pyrito

@rhshadrach this is awesome and a lot clearer. I was looking at the pandas 1.5.3 docs.

Comment From: rhshadrach

Sounds like this is resolved. Improvements to the docs are always welcome. If there is anything further you'd like to raise here, just comment and we can reopen.