How can I check for NaN values?
Use math.isnan
:
>>> import math
>>> x = float('nan')
>>> math.isnan(x)
True
The usual way to test for a NaN is to see if it's equal to itself:
def isNaN(num):
return num != num
Use math.isnan
:
>>> import math
>>> x = float('nan')
>>> math.isnan(x)
True
The usual way to test for a NaN is to see if it's equal to itself:
def isNaN(num):
return num != num