A common task in data cleaning is managing "NaN" (Not a number) values. Which…

2026

A common task in data cleaning is managing "NaN" (Not a number) values. Which Pandas function allows you to replace all missing values in a DataFrame with a specific value, such as 0?

  1. A.

    df.dropna()

  2. B.

    df.isna()

  3. C.

    df.fillna()

  4. D.

    df.replace_nan()

Attempted by 99 students.

Show answer & explanation

Correct answer: C

The correct function to replace missing values (NaN) with a specific value like 0 in Pandas is fillna(). For example, df.fillna(0) replaces all NaN values with 0. Other functions like dropna() remove rows containing missing values, and isna() checks for them without replacing.

Explore the full course: Bpsc