# Grouping with groupby

groupby sorts a table's rows into groups that share a value, such as a neighborhood, works out one number for each group (a sum, a mean, a count) and hands back one row per group, which answers "which one sold the most?" in a line instead of a filter for every group.

![Cheat sheet: Grouping with groupby](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/6523d678cf9e43c0a39422add3e4f2a2.webp)

- Category: Data Analysis
- Level: Apprentice
- Tags: group by, GroupBy(), python, Split-Apply-Combine
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/pandas-groupby-cheat-sheet
