Match a list of values with isin
A pandas exercise from Pandasdrill. Solve it with a Python editor in your browser running real pandas, and it is checked the moment you submit.
The task
Return the employees who work in Boston or Denver. Keep all columns and the original row labels.
What this exercise teaches
isin is the tidy way to write several equality checks joined with or. It returns a boolean mask you can use to filter the rows.
A hint if you get stuck
Series.isin takes a list and marks each row True when its value is in the list.
Try it now, no account needed
This exercise is free. Open it on the practice page, solve it, and get instant feedback with a hint and a worked solution after two tries.
Open this exercise