Courseiva

DA0-002 Data Acquisition and Preparation Practice Question

You are using pandas in Python to clean a dataset. You notice several rows with missing values in the 'age' column. Which method would you use to remove those rows?

⚠ Common exam trap

A common mix-up: candidates confuse methods for detecting missing values (isna) with those for removing them (dropna), or mistakenly thinking fillna removes rows when it actually replaces values.

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

✓

df.dropna()

The df.dropna() method is specifically designed to remove rows (or columns) that contain missing values (NaN). By default, it drops any row where at least one NaN is present, which directly addresses the requirement to remove rows with missing 'age' values. This is the standard pandas approach for handling incomplete records when deletion is preferred over imputation.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    df.drop_duplicates()

    Why it's wrong here

    drop_duplicates() removes rows duplicated across all columns, so it leaves the missing 'age' entries untouched. It is tempting because it does eliminate rows, but its purpose is de-duplication, not handling nulls; dropna() targets missing values directly.

  • ✓

    df.dropna()

    Why this is correct

    `df.dropna()` removes every row containing any null value, directly satisfying the requirement to eliminate rows with missing 'age' entries. Its default `axis=0` and `how='any'` parameters target rows rather than columns, so the cleaned DataFrame retains only complete records without additional filtering logic.

  • ✗

    df.fillna(0)

    Why it's wrong here

    fillna(0) substitutes zero for each missing 'age' value, retaining every row rather than removing it. It is tempting because it addresses nulls, but its purpose is imputation; dropna() is the method that actually deletes rows containing missing values.

  • ✗

    df.isna()

    Why it's wrong here

    df.isna() returns a boolean mask marking missing cells; it removes nothing on its own. It is tempting because it is the standard first step for detecting nulls, which suits profiling or feeding a mask into df.dropna() or boolean indexing. Direct row removal requires dropna() or filtering with the mask.

About these practice questions

This DA0-002 question is part of Courseiva's 1,004-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official CompTIA exam blueprint

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.