Drop rows missing a key field
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
Drop the contacts that have no email. Contacts without a phone number stay. Keep the original row labels.
What this exercise teaches
dropna() with no arguments drops a row if any column is missing, which would also remove contacts that only lack a phone. subset=["email"] checks just the email column.
A hint if you get stuck
dropna has a subset parameter that limits which columns are checked for missing values.
This exercise is part of Pro
Pro unlocks all 45 exercises, with worked solutions and progress saved to your account. The free exercises work without an account.
You create a free account first, so Pro is attached to it.
Monthly is charged today and then every month until you cancel, in one click from your account page. Lifetime is one payment with no renewals. Full refund within 14 days of paying.