[Numpy-discussion] argmax for top N elements

eat e.antero.tammi@gmail....
Wed Jun 22 10:44:28 CDT 2011


Hi,

On Wed, Jun 22, 2011 at 6:30 PM, Alex Flint <alex.flint@gmail.com> wrote:

> Is it possible to use argmax or something similar to find the locations of
> the largest N elements in a matrix?

How bout argsort(.)?, Like:
In []: a= arange(9)
In []: a.argsort()[::-1][:3]
Out[]: array([8, 7, 6])

My 2 cents,
eat

>

_______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110622/663f9b1b/attachment-0001.html 


More information about the NumPy-Discussion mailing list