[Numpy-discussion] Replacing NANs

Angus McMorland amcmorl at gmail.com
Tue Mar 30 15:02:59 EDT 2010

On 30 March 2010 14:59, Vishal Rana <ranavishal at gmail.com> 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?

ar[np.isnan(ar)] = my_num

where ar is your array and my_num is the number you want to replace nans with.


> Thanks
> Vishal
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh

More information about the NumPy-Discussion mailing list