Count the rows that match
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
How many employees in `emp` earn more than 70,000? Return a single number, not a table.
What this exercise teaches
Summing a boolean Series counts its True values, because True is 1 and False is 0. count() is the usual mistake here: it counts every value that is not missing, True or False alike, so it returns the number of rows.
A hint if you get stuck
A comparison gives a Series of True and False. True counts as 1, so adding the Series up counts the rows that match.
Try it now, free, no account needed
Your first 8 exercises on Pandasdrill are free. Open it on the practice page, solve it, and get instant feedback with a hint. A free account adds the worked solution; Pro unlocks every exercise, timed mode and the certificate.
Open this exercise