Which pandas or cuDF operation fills missing temperature readings with the column median?
- Exam domain
- Data Manipulation and Preparation23% of the exam
- Difficulty
- Easy
- In this mock
- 11 questions on this domainPractise this domain
Why the exam asks this
Data Manipulation and Preparation (23% of the exam)
Objective in the exam guide: Data cleaning, quality handling, and governance compliance
Data quality handling is core to preparation.
Why D is the answer
fillna with the median value
fillna replaces missing values with a given value, here the median. dropna removes rows instead.
Remember: fillna replaces missing values.
How it works
Missing values are filled, dropped or modelled, and the choice is recorded.
In detail
- fillna replaces missing values.
- dropna removes them.
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. dropna on every rowWrongMost tempting
dropna loses rows.
Why it tempts: Dropping rows is simple.
B. sort_values on the columnWrong
Sorting does not fill gaps.
C. astype to stringWrong
Casting to string hides the problem.
D. fillna with the median valueRight
fillna replaces missing values.
Use case
An illustrative scenario, not a real incident.
Illustrative: filling 2% of missing readings with the median keeps all rows for training.
See it in different ways
flowchart TD
Q{"How many are missing?"}
Q -->|"Few"| A0["Fill with median or model"]
Q -->|"Most of the column"| A1["Drop the column"]
Q -->|"Whole rows empty"| A2["Drop rows"]How to read this chart
- At "How many are missing?": if "Few", go to "Fill with median or model"; if "Most of the column", go to "Drop the column"; if "Whole rows empty", go to "Drop rows".
flowchart LR S0["Count missing"] --> S1["Choose strategy"] --> S2["Fill or drop"] --> S3["Record the choice"]
How to read this chart
- Read it in order: Count missing, then Choose strategy, then Fill or drop, then Record the choice.