Skip to content

Commit 86d51ce

Browse files
committed
DOC: Add real-world aggregation example to GroupBy user guide
1 parent cc4f585 commit 86d51ce

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

doc/source/user_guide/groupby.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,19 @@ column in a group of values.
488488
animals
489489
animals.groupby("kind").sum()
490490
491+
Another real-world style example using sales data:
492+
493+
.. ipython:: python
494+
495+
df = pd.DataFrame({
496+
"Region": ["East", "West", "East", "West"],
497+
"Sales": [250, 300, 150, 200]
498+
})
499+
df
500+
df.groupby("Region")["Sales"].sum()
501+
502+
503+
491504
In the result, the keys of the groups appear in the index by default. They can be
492505
instead included in the columns by passing ``as_index=False``.
493506

0 commit comments

Comments
 (0)