How does pandas represent missing values, and what is the difference between NaN, NaT, and pd.NA?

Quick Overview

Explain how pandas marks missing data with NaN, NaT and pd.NA, which column types use each marker, and how each behaves in comparisons and arithmetic. Tests working knowledge of pandas dtypes, nullable extension types and correct missing-value checks.

How does pandas represent missing values, and what is the difference between NaN, NaT, and pd.NA?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Other

How does pandas represent missing values, and what is the difference between `NaN`, `NaT`, and `pd.NA`? Cover which marker shows up in which kind of column and how each one behaves when you compare it or compute with it. ```hint Start from the dtype Each marker belongs to a family of column types. Ask what happens to a plain integer column when one of its values goes missing. ``` ```hint Try a comparison Evaluate `x == x` for each marker and look at what comes back. ``` ### What a Strong Answer Covers - Which marker appears in float and object columns, which in datetime and timedelta columns, and which in the nullable extension dtypes - How each marker behaves in equality comparisons and arithmetic, including the three-valued logic of `pd.NA` - Why classic integer and boolean columns change dtype when a value goes missing, and how nullable dtypes avoid that - The correct way to detect missing values and why `== np.nan` fails ### Follow-up Questions - How do `sum`, `mean`, `groupby` and `value_counts` treat missing values by default, and how do you change that? - What happens when you filter a DataFrame with a nullable boolean mask that contains `pd.NA`? - When would you run `convert_dtypes()` on a DataFrame, and what can change downstream when you do? - How does a `None` in the input end up stored in a float column compared with an object column?

Overview: Explain how pandas marks missing data with NaN, NaT and pd.NA, which column types use each marker, and how each behaves in comparisons and arithmetic. Tests working knowledge of pandas dtypes, nullable extension types and correct missing-value checks.

General logo
General
Nov 25, 2026
mediumData ScientistOtherData Manipulation (SQL/Python)
0
0

How does pandas represent missing values, and what is the difference between NaN, NaT, and pd.NA?

Cover which marker shows up in which kind of column and how each one behaves when you compare it or compute with it.

What a Strong Answer Covers Guidance

  • Which marker appears in float and object columns, which in datetime and timedelta columns, and which in the nullable extension dtypes
  • How each marker behaves in equality comparisons and arithmetic, including the three-valued logic of pd.NA
  • Why classic integer and boolean columns change dtype when a value goes missing, and how nullable dtypes avoid that
  • The correct way to detect missing values and why == np.nan fails

Follow-up Questions Guidance

  • How do sum , mean , groupby and value_counts treat missing values by default, and how do you change that?
  • What happens when you filter a DataFrame with a nullable boolean mask that contains pd.NA ?
  • When would you run convert_dtypes() on a DataFrame, and what can change downstream when you do?
  • How does a None in the input end up stored in a float column compared with an object column?