Most summary questions ask for one figure for each of several groups, and groupby answers exactly that.
Calling groupby on its own shows nothing useful; it returns an object that waits for a calculation.
The split step works out which rows belong to which group.
The apply step runs the calculation once per group, and the combine step joins the results into a new table.
Built-in calculations such as sum, mean, count, min and max are vectorised and fast.
The count method skips blanks while size counts every row, so the two can differ for the same group.
Grouping by two columns, such as region and month, gives one result for each combination.
By default the group labels become the index, and as_index=False keeps them as ordinary columns.
The transform method returns a result as long as the original, such as each order's share of its region's total.
Rows with a blank group label are dropped by default, which can hide a whole group from the summary.
Passing dropna=False keeps those rows as a group of their own.
Using apply with a custom Python function is flexible but much slower than the built-in calculations.
Groupby on millions of rows stays fast as long as it sticks to built-in calculations.
In practice groupby is how most reports start: totals by month, averages by team, counts by status.
A common misconception is that groupby changes the table; it only builds summaries and leaves the rows as they were.