0PricingLogin
Data Science Academy · Lesson

Combine Filters With AND and OR

Chaining multiple conditions safely.

One Condition Is Rarely Enough

Real questions stack conditions: adults in Paris, or orders that are late and large. You need to combine filters cleanly. 🧩

Use the Ampersand for AND

To require both conditions, join the two masks with the ampersand. It works element by element across the rows.

df[(df["age"] > 30) & (df["city"] == "Paris")]

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