0PricingLogin
Data Science Academy · Lesson

Filter Rows With Conditions

Boolean masks on a DataFrame.

From Columns to Rows

Picking columns trims width; filtering rows trims length. Now you keep only the records that match a condition you care about. 🔍

A Condition Makes a Mask

Write a comparison on a column and pandas returns a boolean mask: one True or False per row, telling you which records pass.

mask = df["age"] > 30
print(mask.head())

All lessons in this course

  1. Pick Columns by Name
  2. Filter Rows With Conditions
  3. Combine Filters With AND and OR
  4. query and isin for Clean Filters
← Back to Data Science Academy