5. You have a dataset with columns ['name', 'age', 'income']. Some age values are missing, and some income values are negative due to data entry errors. Which sequence of cleaning steps is best to prepare data for analysis?
hard
A. Delete all rows with missing 'age', then fill negative 'income' with mean
B. Fill missing 'age' with median, then replace negative 'income' with zero
C. Fill missing 'age' with zero, then delete rows with negative 'income'
D. Replace negative 'income' with median, then fill missing 'age' with mean
Solution
Step 1: Handle missing 'age' values
Filling missing 'age' with median preserves data without bias from zeros or deletion.
Step 2: Fix negative 'income' errors
Replacing negative 'income' with zero corrects errors without deleting data.
Final Answer:
Fill missing 'age' with median, then replace negative 'income' with zero -> Option B
Quick Check:
Median fill + zero fix = best cleaning [OK]
Hint: Fill missing with median; fix errors with zero [OK]
Common Mistakes:
Deleting rows unnecessarily
Filling missing with zero causing bias
Replacing errors with mean without fixing negatives
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.