# NumArray array-indexing

Michael Drumheller drumheller at alum.mit.edu
Mon Aug 16 08:50:05 CEST 2004

```Christopher T King <squirrel at WPI.EDU> wrote in message news:<Pine.LNX.4.44.0408121433170.9323-100000 at ccc8.wpi.edu>...
> On 12 Aug 2004, Michael Drumheller wrote:
>
> > I am new to NumArray and I wonder if someone can help me with
> > array-indexing.  Here's the basic situation: Given a rank-2 array
> > (i.e., a matrix) it seems to be trivial, with array indexing,
> > to extract a subset of its *columns*.  But it does not seem
> > to be trivial to extract a subset of its *rows*.
>
> You can do this using slices, like so:
>
> >>> from numarray import *
> >>> a = array([[1, 2], [3, 4]])
> >>> a[:,1]
> array([2, 4])
>
> ':' means 'take all values along this axis', just like how with standard
> Python lists it means 'take all values in the list'.

But that just gets me *one* column.  I was trying to extract
an arbitrary subset of columns.  Like I pointed out in the example
code I gave, this is trivial get take(), but does not seem to
be trivial with array indexing (and impossible with slicing).
Mike

```