# Filtering

Filtering: Filtering Rows with a Condition, Combining Conditions with &, | and ~.

Updated: November 19, 2026

1. [Filtering Rows with a Condition](https://www.ask-codey.com/lessons/pandas-filtering-rows) (Apprentice): A comparison such as products\["price"\] &lt; 100 gives a True or False answer for every row, called a mask; putting the mask in square brackets, products\[mask\], keeps only the rows where it is True; and sum() and mean() on the mask count the matching rows and give their share of the table.
2. [Combining Conditions with &, | and ~](https://www.ask-codey.com/lessons/pandas-combining-conditions) (Apprentice): Python's and, or and not can't combine whole columns of True and False, so pandas uses & (and), | (or) and ~ (not), with parentheses around each comparison; isin, between and str.contains replace long chains of conditions, and query writes a filter as text.

Source: https://www.ask-codey.com/courses/python-data-analysis/topics/data-filtering
