Python NaN and validation

I am making a program where I optimize some values. Due to the equations from time to time my NaN values

My problem, some of the entries are NaN.

I would like to know if there is a test to verify their logical validity, so I can skip these values ​​and try again.

So far I have tried checking

a==np.nan, a==nan, b=aa==b 

To no avail.

I hope you help me.

thanks

+6
source share
2 answers

Using numpy,

 import numpy as np np.isnan(np.nan) # returns True 
+21
source

With Python 2.6, you want to import math and use math.isnan(a) .

See http://docs.python.org/library/math.html#math.isnan

+6
source

Source: https://habr.com/ru/post/888209/


All Articles