[Numpy-discussion] Replacing NANs

Zachary Pincus zachary.pincus@yale....
Tue Mar 30 14:05:41 CDT 2010


> In an array I want to replace all NANs with some number say 100, I  
> found a method nan_to_num but it only replaces with zero.
> Any solution for this?

Indexing with a mask is one approach here:

a[numpy.isnan(a)] = 100

also cf. numpy.isfinite as well in case you want the same with infs.

Zach


On Mar 30, 2010, at 2:59 PM, Vishal Rana wrote:

> Hi,
>
> In an array I want to replace all NANs with some number say 100, I  
> found a method nan_to_num but it only replaces with zero.
> Any solution for this?
>
> Thanks
> Vishal
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion



More information about the NumPy-Discussion mailing list