Python
All Top Python Interview Questions#21
Detect and Quantify Missing Values with isna().sum() in Pandas
EasyPwCInterview Question #21
Asked at PwCGiven a dataset, write a function that returns a summary DataFrame listing each column, its total count of missing values, and the percentage of missing values rounded to 2 decimal places.
Input Table: df
20 rows preview| customer_id | name | phone | |
|---|---|---|---|
| 1 | Aarav | aarav@example.com | 9820011111 |
| 2 | Bhavna | NULL | 9820022222 |
| 3 | Chirag | chirag@example.com | 9820033333 |
| 4 | Divya | divya@example.com | 9820044444 |
| 5 | Esha | NULL | 9820055555 |
| 6 | Farhan | farhan@example.com | 9820066666 |
| 7 | Gauri | gauri@example.com | 9820077777 |
| 8 | Harsh | NULL | 9820088888 |
| 9 | Isha | isha@example.com | 9820099999 |
| 10 | Jatin | jatin@example.com | NULL |
| 11 | Kavya | kavya@example.com | 9820011112 |
| 12 | Lakshay | NULL | 9820011113 |
| 13 | Meera | meera@example.com | 9820011114 |
| 14 | Naveen | naveen@example.com | 9820011115 |
| 15 | Omkar | omkar@example.com | 9820011116 |
| 16 | Priya | priya@example.com | 9820011117 |
| 17 | Qasim | qasim@example.com | 9820011118 |
| 18 | Riya | riya@example.com | 9820011119 |
| 19 | Sahil | sahil@example.com | 9820011120 |
| 20 | Tara | tara@example.com | 9820011121 |
Expected Output Structure2 rows
| column | missing_count | missing_pct |
|---|---|---|
| 4 | 20 | |
| phone | 1 | 5 |
Interview Context
Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.
Python 3.10 (Pandas)
Environment Ready
Starting the real Python + pandas runtime (one-time download)…