Ravindra BagaleCourses & study guides

7. GroupBy and Aggregations

7.3 value_counts vs GroupBy

df["city"].value_counts()
df.groupby("city").size()          # similar counts
df.groupby("status")["amount"].sum()

Worked example. Ruhi Bagale compares Diwali vs None GMV for Pune before sending a note to Ravindra Bagale (city manager).

Practice task

Add a platform column (Blinkit / Amazon Now). Group by platform and city to get GMV and order counts. Sort by GMV descending.

Thodkyaat sangaycha tar (quick recap)

  • groupby = split–apply–combine
  • Named aggregations give clean report columns
  • Use nunique on order_id when grain is line-level

Samajla ka? Aata pudhe jaauya combining data — concat and merge.