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

William Furnass will@thearete.co...
Mon Feb 13 13:52:30 CST 2012


Thank you, that does the trick.

Regards,

Will

On 13 February 2012 19:39, Travis Oliphant <travis@continuum.io> 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( [neighbourhoods[i][perf[neighbourhoods].argmax(axis=1)[i]]
>> for i in xrange(neighbourhoods.shape[0])] )
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion


More information about the NumPy-Discussion mailing list