# [Numpy-discussion] Re place array values

Derek Ashley Thomas derekathomas@gmail....
Wed Mar 14 18:57:48 CDT 2012

```Hi,
I'm completely new to this list (and fairly new to numpy in general), but I
was wondering if you tried multiplying the bool array and the original
array.

Try:
x=array([[0,1,2],[3,4,5],[6,7,8]])

if rank(x) <= 1
dot(x>=1, x)
else
(x>=1)*x

This will give you a completely numerical array of the same structure, but
all numbers less than 1 will be zero fo easy handling. Is this what you're
trying to accomplish?

--
Derek

On Thu, Mar 15, 2012 at 08:35, jonasr <jonas.ruebsam@web.de> wrote:

>
> Hello,
>
> my problem is that i want to remove some small numbers of an 2d array,
> for example if i want to sort out all numbers smaller then 1 of an array i
> get
>
> x=[[0,1,2],[3,4,5][6,7,8]]
>
> c=x>=1
>
> In [213]: c
> Out[213]:
> array([[False,  True,  True],
>       [ True,  True,  True],
>       [ True,  True,  True]], dtype=bool)
>
> In [214]: x[c]
> Out[214]: array([1, 2, 3, 4, 5, 6, 7, 8])
>
> the problem ist that i now have a 1d array, is there any possibility to
> keep the 2d structure ?
>
> greets jonas
> --
> View this message in context:
> http://old.nabble.com/Replace-array-values-tp33506446p33506446.html
> Sent from the Numpy-discussion mailing list archive at Nabble.com.
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120315/18dcdf84/attachment.html
```