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
On 30 March 2010 14:59, Vishal Rana ranavis...@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
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
That was quick!
Thanks Angus and Zachary
On Tue, Mar 30, 2010 at 11:59 AM, Vishal Rana ranavis...@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?
*
*Thanks
Vishal