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?

Answer: C. df.fillna()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…

  1. A.

    df.dropna()

  2. B.

    df.isna()

  3. C.

    df.fillna()

  4. D.

    df.replace_nan()

Attempted by 171 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: Hpsc Pgt Computer Science

Loading lesson…