NaN (Pandas)
NaN ('Not a Number') is a floating-point value used to represent missing or undefined numeric results. It is not equal to itself. Use isna() to detect missing data across Pandas' different missing-value markers.
Pandas
Floating-point NaN is one missing-value marker, not a universal scalar used by every dtype. Datetime data uses NaT, and nullable Pandas dtypes can use pd.NA. Ordinary integer arrays cannot store floating-point NaN without changing dtype; nullable Int64 represents a missing integer explicitly.
For a floating-point NaN value, value == value is False and value != value is True. Missing-value masks also recognise None, NA and NaT where appropriate, so isna()/notna() is clearer than relying on a comparison trick.
Many reductions skip missing observations by default. A mean then describes known observations, and an all-missing sum can default to zero. Choose an explicit observation requirement or missing-data policy before treating a summary as complete.
Syntax
import numpy as np; value = np.nan | s.isna()Examples
Python
import pandas as pd
value = float("nan")
print(value == value)
print(value != value)
values = pd.Series([0, value, None, pd.NA], dtype="object")
print(values.isna().tolist())Output:
False
True
[False, True, True, True]