0PricingLogin
Data Science Academy · Lesson

Group by Several Keys

Multi-level grouping and the result index.

Group on More Than One Column

Pass a list of keys to groupby and pandas forms a group for every unique combination of those columns.

df.groupby(["city", "year"])

Every Combo Is a Group

Two cities and three years can yield up to six groups, one per existing combination found in your data.

All lessons in this course

  1. Split-Apply-Combine Explained
  2. Multiple Aggregations With agg
  3. Group by Several Keys
  4. transform for Group-Wise Features
← Back to Data Science Academy