Search⌘ K
AI Features

NaN Values in Series

Explore how pandas represents missing numeric data using NaN in Series. Understand its effect on data types and operations, and gain insight into working with nullable integer types and missing values in data analysis.

The NaN value

A value that may be familiar to NumPy users, but not Python users in general, is NaN. When pandas determines that a series holds numeric values but cannot find a number to represent an entry, it will use NaN. This value stands for “Not A Number” and is usually ignored in arithmetic operations. (Similar to NULL in SQL.)

Here’s a series that has NaN in it:

Python 3.8
import pandas as pd
import numpy as np
nan_series = pd.Series([2, np.nan], index=['Ono', 'Clapton'])
print(nan_series)

Note: One thing to note is that the type of this Series is float64, not int64 ...