WeCodeAcademy

Grouping and Summarizing

groupby splits the rows into groups, then you summarise each group: mean, sum, count, or several at once with agg. It is the Pandas version of SQL's GROUP BY.

Examplepython
Open in editor »
Quick check

`df.groupby('city')['age'].mean()` returns...

Your turn: write the code

Print the number of people in each city (size).

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.