Filtering is the most common step in data work, because most questions are about part of the data.
The mechanism is a boolean mask: a Series of True and False values, one for each row of the table.
pandas lines the mask up with the rows by index label and keeps the rows marked True.
Comparisons run on whole columns at once, so building a mask is vectorised and fast.
The & and | operators need brackets around each comparison, because they bind more tightly than > or ==.
Python's own and and or raise an error on a Series, since a whole column has no single truth value.
The isin method checks membership in a list, such as keeping rows whose region is North or South.
The between method keeps values within a range, and str.contains matches text inside a column.
A blank fails greater than, less than and equals tests, so a price filter quietly drops rows where the price is empty.
Checking the row count before and after a filter shows how much was removed.
The query method offers a shorter form, such as sales.query("price > 100 and qty > 5").
A filtered result can behave like a copy, so changes should go through loc on the original table.
Filtering early keeps every later step smaller and faster.
It is the pandas version of a SQL WHERE clause, and the logic carries straight across.
A filter that silently matches nothing is the usual trap, such as testing for north when the data says North.