numpy.nan

Full name
numpy.nan
Library
NumPy
Syntax

numpy.nan

Description

numpy.nan is a special value from the NumPy library that represents the null value.

Parameters

numpy.nan does not accept arguments.

Result

numpy.nan returns a value of type float.

Examples

We can create a NumPy array that includes null values with the following code:

a = np.array([2, np.nan, 4, 1, np.nan])
a

array([2., nan, 4., 1., nan])

Note that the result is an array of type float, as it includes both integer and real values (the null values):

a.dtype

dtype('float64')

Submitted by admin on Sat, 01/16/2021 - 12:55