[Numpy-discussion] Setting small numbers to zero.
josef.pktd@gmai...
josef.pktd@gmai...
Wed Mar 17 10:57:05 CDT 2010
On Wed, Mar 17, 2010 at 11:56 AM, Keith Goodman <kwgoodman@gmail.com> wrote:
> On Wed, Mar 17, 2010 at 8:51 AM, gerardob <gberbeglia@gmail.com> wrote:
>>
>> How can i modified all the values of a numpy array whose value is smaller
>> than a given epsilon to zero?
>>
>> Example
>> epsilon=0.01
>> a = [[0.003,2][23,0.0001]]
>>
>> output:
>> [[0,2][23,0]]
>
> Here's one way:
>
>>> a = np.array([[0.003,2],[23,0.0001]])
>>> a[np.abs(a) < 0.01] = 0
>>> a
>
> array([[ 0., 2.],
> [ 23., 0.]])
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
But as Skipper said before
You might find these helpful.
http://www.scipy.org/Tentative_NumPy_Tutorial
http://www.scipy.org/Numpy_Example_List
Josef
More information about the NumPy-Discussion
mailing list