[Numpy-discussion] Indexing 2d arrays by column using an integer array

Travis Oliphant travis@continuum...
Mon Feb 13 13:39:10 CST 2012


I think the following is what you want: 

neighborhoods[range(9),perf[neighbourhoods].argmax(axis=1)]

-Travis


On Feb 13, 2012, at 1:26 PM, William Furnass wrote:

> np.array( [neighbourhoods[i][perf[neighbourhoods].argmax(axis=1)[i]]
> for i in xrange(neighbourhoods.shape[0])] )



More information about the NumPy-Discussion mailing list