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

All selecting and filtering commands · pandas and NumPy 3 cheatsheet

Was this page helpful?