NaN

noun

say it: “NAN” /ˈnæn/

Short for 'not a number': the mark pandas and NumPy show in a table where a value is missing.

What does NaN mean in pandas?

NaN, read "not a number", is pandas' mark for a missing value in a table. Math leaves it out: mean() averages only the values that are there, and count() counts only those, so a column full of NaN can give a confident-looking answer from a few rows.

import pandas as pd
ages = pd.Series([3.0, None, 5.0, None])
print(ages)            # 3.0, NaN, 5.0, NaN
print(ages.mean())     # 4.0: the two NaN are left out

In a sentence

  • “pd.to_numeric turned 'about 15' into NaN because it isn't a number.”
  • “The breed column showed NaN wherever the volunteer left it blank.”

Level: Apprentice · More Python terms at this level

Updated

In other subjects