pandas and NumPy 3 · Selecting and filtering
Filter rows
Keep rows that meet conditions. Combine them with & and |, each in parentheses.
df[(df["age"] > 30) & (df["country"] == "UK")]
Official pandas and NumPy 3 documentation
More selecting and filtering commands
- Select columns
- Filter with a string expression
- Select by label
- Select by position
- Match a list of values
- Sort rows
All selecting and filtering commands · pandas and NumPy 3 cheatsheet