How can I check for NaN values?

Use math.isnan:

>>> import math
>>> x = float('nan')
>>> math.isnan(x)
True

Leave a Comment