Day 8 of 14 35 mingroupby()agg()transform()
Summarise data by category with groupby. Split rows into groups, calculate totals, averages and counts per group, use several aggregations at once with named results, add group totals back to every row with transform(), and keep or drop whole groups with filter().
By the end of today you can
- Explain split-apply-combine and use groupby() with one or several keys
- Aggregate with sum, mean, count and size, and know the difference between count and size
- Produce tidy summaries with named aggregation in agg()
- Add group-level values to every row with transform()
- Find the top N rows in each group and filter out whole groups
What's inside
- 6 sections
- 3 diagrams and mind maps
- 8 code examples you can run
- 5-question quiz
- 1Split, apply, combine
- 2Grouping by several columns
- 3count vs size
- 4agg(): several results at once
- 5transform(): group values on every row
- 6Top N per group, and filter()
Sign in free to read this lesson
Get the full lesson with diagrams, runnable code and the quiz. Your progress is saved across devices.
Sign in free