snippetpythonCriticalCanonical
How to check for NaN values
Viewed 0 times
howcheckfornanvalues
Problem
float('nan') represents NaN (not a number). But how do I check for it?Solution
Use
math.isnan:>>> import math
>>> x = float('nan')
>>> math.isnan(x)
TrueCode Snippets
>>> import math
>>> x = float('nan')
>>> math.isnan(x)
TrueContext
Stack Overflow Q#944700, score: 2210
Revisions (0)
No revisions yet.