Stage 1 · Lesson 5 of 7
Grouping and summarising
Grouping splits rows by one or more columns, computes a summary for each group, and combines the results into a new table: people call it split, apply, combine. It is how you get orders per region, average score per or revenue per month.
In it is groupby followed by agg; in R it is group_by followed by summarise. Name your output columns clearly and count rows in each group alongside every average, so a group of 3 is not mistaken for one of 3,000.
Common trapaveraging averages: the mean of per-region means is not the overall mean when regions have different numbers of rows, so compute overall figures from the raw rows or weight by group size.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking Python Fundamentals
Design Gurus · Beginner · $50
Solid Python basics first: data types, collections, functions and files, the ground pandas stands on
- CourseFreeKaggle Learn
Kaggle · Beginner
Free: the Python and Pandas courses, short lessons with exercises that run in the browser