[Numpy-discussion] simple indexing question

Neal Becker ndbecker2@gmail....
Wed Sep 23 08:48:49 CDT 2009

I have an array:
In [12]: a
array([[0, 1, 2, 3, 4],
       [5, 6, 7, 8, 9]])

And a selection array:
In [13]: b
Out[13]: array([1, 1, 1, 1, 1])

I want a 1-dimensional output, where the array b selects an element from 
each column of a, where if b[i]=0 select element from 0th row of a and if 
b[i]=k select element from kth row of a.

Easy way to do this?  (Not a[b], that gives 5x5 array output)

More information about the NumPy-Discussion mailing list