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

2012-02-13 Thread William Furnass
Thank you, that does the trick. Regards, Will On 13 February 2012 19:39, Travis Oliphant wrote: > 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( [neighbo

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

2012-02-13 Thread Travis Oliphant
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])] ) ___

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

2012-02-13 Thread William Furnass
Hi, Apologies if the following is a trivial question. I wish to index the columns of the following 2D array In [78]: neighbourhoods Out[78]: array([[8, 0, 1], [0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7,