# [Numpy-discussion] Index update

Tue Jan 10 14:53:52 CST 2012

```Thanks - very cool!

On 10/01/2012 21:45, Val Kalatsky wrote:
>
> A - np.digitize(A, S)
> Should do the trick, just make sure that S is sorted and A and S do
> not overlap,
> if they do remove those items from A using set operations.
> Val
>
> On Tue, Jan 10, 2012 at 2:14 PM, Mads Ipsen <madsipsen@gmail.com
>
>     Hi,
>
>     Suppose you have N items, say N = 10.
>
>     Now a subset of these items are selected given by a list A of
>     indices. Lets say that items A = [2,5,7] are selected. Assume now
>     that you delete some of the items given by the indices S =
>     [1,4,8]. This means that the list of indices A must be updated,
>     since items have been deleted. For this particular case the
>     updated selection list A becomes A = [1,3,5].
>
>     Is there some smart numpy way of doing this index update of the
>     selected items in A without looping? Typically N is large.
>
>     Best regards,
>
>
>     --
>     +-----------------------------------------------------+
>     +----------------------+------------------------------+
>     | Gåsebæksvej 7, 4. tv |                              |
>     | DK-2500 Valby        | phone:+45-29716388  <tel:%2B45-29716388>  |
>     +----------------------+------------------------------+
>
>
>
>     _______________________________________________
>     NumPy-Discussion mailing list
>     NumPy-Discussion@scipy.org <mailto:NumPy-Discussion@scipy.org>
>     http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

--
+-----------------------------------------------------+
+----------------------+------------------------------+
| Gåsebæksvej 7, 4. tv |                              |
| DK-2500 Valby        | phone:          +45-29716388 |
| Denmark              | email:  mads.ipsen@gmail.com |
+----------------------+------------------------------+

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120110/ff6500e6/attachment.html
```