[Numpy-discussion] Fill a particular value in the place of number satisfying certain condition by another number in an array.
Fabrice Silva
silva@lma.cnrs-mrs...
Mon Aug 1 04:43:13 CDT 2011
Le lundi 01 août 2011 à 15:01 +0530, dileep kunjaai a écrit :
> Dear sir,
> How can we fill a particular value in the place of number satisfying
> certain condition by another number in an array.
> A contain some negative value i want to change the negative numbers to
> '0'. I used 'masked_where', command but I failed.
Does np.clip fulfill your requirements ?
http://docs.scipy.org/doc/numpy/reference/generated/numpy.clip.html
Be aware that it needs an upper limit (which can be np.inf).
Another option
A[A<0] = 0.
--
Fabrice Silva
More information about the NumPy-Discussion
mailing list