python – How can I check for NaN values?
python – How can I check for NaN values?
Return
True
if x is a NaN (not a number), andFalse
otherwise.
>>> import math
>>> x = float(nan)
>>> math.isnan(x)
True
The usual way to test for a NaN is to see if its equal to itself:
def isNaN(num):
return num != num
python – How can I check for NaN values?
numpy.isnan(number)
tells you if its NaN
or not.