numpy.isnan

numpy.isnan(x[, out])

Returns a numpy boolean scalar or array resulting from an element-wise test for Not a Number (NaN).

Parameters:

x : array_like

input data.

Returns:

y : {ndarray, bool}

For scalar input data, the result is a new numpy boolean with value True if the input data is NaN; otherwise the value is False.

For array input data, the result is an numpy boolean array with the same dimensions as the input and the values are True if the corresponding element of the input is Not a Number; otherwise the values are False.

See also

isinf
Tests for infinity.
isneginf
Tests for negative infinity.
isposinf
Tests for positive infinity.
isfinite
Shows which elements are not: Not a number, positive infinity and negative infinity

Notes

Numpy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754). This means that Not a Number is not equivalent to infinity.

Examples

>>> np.isnan(np.nan)
True
>>> np.isnan(np.inf)
False
>>> np.isnan([np.log(-1.),1.,np.log(0)])
array([ True, False, False], dtype=bool)

Previous topic

numpy.isinf

Next topic

numpy.isneginf

This Page

Quick search