Lesson 4.2

Filtering, grouping, and aggregation

Almost every analytical question is the same shape: split the rows into groups, apply an aggregation to each, and combine the results.

27mBeginner15.4k students

Overview

Split, apply, combine

Almost every analytical question is the same shape: split the rows into groups, apply an aggregation to each, and combine the results. Once you see it, group-by stops being syntax and becomes the tool you reach for.

Boolean masks compose with and-or operators, which keeps a multi-condition filter as one readable expression rather than a chain of intermediate frames.

Missing values need a decision, not a default. Dropping them, filling them, or treating them as a category are all defensible; ignoring the question is not, because different operations skip nulls differently.

In this lesson you will:

  • Filter with boolean masks
  • Group and aggregate in one expression
  • Handle missing values on purpose

Resources

Previous Lesson
Next Lesson
Filtering, grouping, and aggregation — Python Foundations for Data Work — Vertex