Drop Missing Data - Problem
You are given a DataFrame called students with the following schema:
| Column Name | Type |
|---|---|
| student_id | int |
| name | object |
| age | int |
Some rows in the DataFrame have missing values in the name column (represented as null or NaN).
Write a solution to remove all rows that contain missing values in the name column and return the cleaned DataFrame.
Input & Output
Example 1 — Basic Missing Data
$
Input:
students = [{"student_id": 1, "name": "Alice", "age": 20}, {"student_id": 2, "name": null, "age": 21}]
›
Output:
[{"student_id": 1, "name": "Alice", "age": 20}]
💡 Note:
Row with student_id=2 has missing name (null), so it's removed. Only Alice's record remains.
Example 2 — Multiple Missing Names
$
Input:
students = [{"student_id": 1, "name": "Bob", "age": 22}, {"student_id": 2, "name": null, "age": 23}, {"student_id": 3, "name": "Charlie", "age": 24}]
›
Output:
[{"student_id": 1, "name": "Bob", "age": 22}, {"student_id": 3, "name": "Charlie", "age": 24}]
💡 Note:
Student with ID 2 has missing name, so removed. Bob and Charlie remain.
Example 3 — No Missing Data
$
Input:
students = [{"student_id": 1, "name": "David", "age": 25}, {"student_id": 2, "name": "Eve", "age": 26}]
›
Output:
[{"student_id": 1, "name": "David", "age": 25}, {"student_id": 2, "name": "Eve", "age": 26}]
💡 Note:
All students have valid names, so no rows are removed.
Constraints
- 1 ≤ students.length ≤ 1000
- Each row contains student_id (int), name (string or null), age (int)
- Missing values in name column are represented as null
Visualization
Tap to expand
Understanding the Visualization
1
Input DataFrame
Original data with some missing names
2
Filter Missing
Remove rows where name is null
3
Clean Output
DataFrame with complete records only
Key Takeaway
🎯 Key Insight: Use pandas dropna() method to efficiently filter out incomplete records
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code