pandas and NumPy 3 · Selecting and filtering

Match a list of values

Keep rows whose value is in a list.

df[df["country"].isin(["UK", "US"])]

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?