Drop Missing Data - Problem

You are given a DataFrame called students with the following schema:

Column NameType
student_idint
nameobject
ageint

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
Drop Missing Data: Clean DataFrame by Removing Missing NamesInput: Original DataFramestudent_idnameage1Alice202null213Bob22⚠ Missing name detecteddropna()Output: Clean DataFramestudent_idnameage1Alice203Bob22✅ Only complete records remainResult: Missing data rows removed, clean DataFrame returned
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
Asked in
Meta 15 Netflix 12
33.8K Views
High Frequency
~5 min Avg. Time
890 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen