[Numpy-discussion] Replacing NANs

Angus McMorland amcmorl@gmail....
Tue Mar 30 14:02:59 CDT 2010


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

Angus.

> Thanks
> Vishal
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@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