There’s a nice trick to check for NaN values without using any imports (np.isnan or even math.isnan), and it relies on the fact that NaN will always be non-equal to anything else, including itself.

value = float('nan')
value != value
#> True