Filtering Rows by Condition
Filtering is how you ask questions of your data. "Show me all sales over $1000" or "Find users from New York."
Pass a condition inside brackets:
df[df['age'] > 30]
This returns only rows where age exceeds 30. The condition creates a boolean Series (True/False for each row), and pandas keeps only the True rows.
Other comparisons work the same way:
df[df['status'] == 'active']
df[df['price'] <= 50]
df[df['name'] != 'Admin']
Filtering is one of the most common operations in data analysis. You'll use it constantly to focus on relevant subsets of your data.
I cover filtering patterns extensively in my Pandas course.