Skip to content

DOC: Add real-world aggregation example to GroupBy user guide #61255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion doc/source/user_guide/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,19 @@ column in a group of values.
animals
animals.groupby("kind").sum()

Another real-world style example using sales data:

.. ipython:: python

df = pd.DataFrame({
"Region": ["East", "West", "East", "West"],
"Sales": [250, 300, 150, 200]
})
df
df.groupby("Region")["Sales"].sum()



In the result, the keys of the groups appear in the index by default. They can be
instead included in the columns by passing ``as_index=False``.

Expand Down Expand Up @@ -1577,7 +1590,8 @@ order they are first observed.
Plotting
~~~~~~~~

Groupby also works with some plotting methods. In this case, suppose we
GroupBy also works with some plotting methods. In this case, suppose we

suspect that the values in column 1 are 3 times higher on average in group "B".


Expand Down
Loading