Filter with a boolean mask
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 every employee in `emp` whose salary is strictly greater than 80,000. Keep all columns and the original row labels.
What this exercise teaches
A comparison on a column gives a boolean Series with one value per row. Indexing the DataFrame with it keeps the rows marked True and keeps their original index labels. Strictly greater means the employee earning exactly 80,000 is left out.
A hint if you get stuck
Build a True/False Series with a comparison, like emp["salary"] > 80000, and put it inside emp[...].
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