DA0-002 Data Acquisition and Preparation Practice Question
A data analyst is using pandas to clean a DataFrame that contains missing values in the 'age' and 'income' columns. Which THREE pandas methods are appropriate for handling missing data? (Select THREE).
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
dropna()
Common pandas methods for missing data include dropna (remove rows with NaN), fillna (replace NaN with a value), and apply with a custom function. Merge is for combining DataFrames; pivot_table is for reshaping.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
dropna()
Why this is correct
The `dropna()` method removes rows or columns containing null values, directly satisfying the requirement to handle missing entries in the 'age' and 'income' columns. It suits scenarios where incomplete records should be excluded entirely, though it risks discarding otherwise valid data when nulls are sparse across the DataFrame.
- ✗
pivot_table()
Why it's wrong here
pivot_table() reshapes data into a cross-tabulated summary; it does not impute or remove nulls. It tempts because pivoting often precedes reporting and can expose gaps visually, so it would be the right method when aggregating values by category, not when handling missing entries.
- ✗
merge()
Why it's wrong here
merge() joins two DataFrames on shared keys; it neither detects nor fills nulls in 'age' and 'income'. It tempts because analysts routinely merge reference tables to enrich data before cleaning, so it would be correct when combining datasets, not when imputing or dropping missing values.
- ✓
apply() with a custom function
Why this is correct
apply() with a custom function lets you define bespoke imputation logic per column, such as filling 'age' with the median and 'income' with a group-wise mean, handling the missing values precisely as the scenario requires.
- ✓
fillna()
Why this is correct
fillna() replaces missing entries with a specified value or a computed statistic, such as the mean age or median income, satisfying the requirement to handle NaN values without discarding rows. Unlike dropna(), it preserves record count, which suits the analyst's need to retain data while imputing gaps in the 'age' and 'income' columns.
About these practice questions
Courseiva writes every DA0-002 question from scratch — 1,004 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DA0-002 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DA0-002 exam.