"isnotnan" functionality in numpy, can this be more pythonic? "isnotnan" functionality in numpy, can this be more pythonic? arrays arrays

"isnotnan" functionality in numpy, can this be more pythonic?


You are currently testing for anything that is not NaN and mtrw has the right way to do this. If you are interested in testing for finite numbers (is not NaN and is not INF) then you don't need an inversion and can use:

np.isfinite(a)

More pythonic and native, an easy read, and often when you want to avoid NaN you also want to avoid INF in my experience.

Just thought I'd toss that out there for folks.


I'm not sure whether this is more or less pythonic...

a = [i for i in a if i is not np.nan]