[Numpy-discussion] argmax for top N elements

eat e.antero.tammi at gmail.com
Wed Jun 22 11:44:28 EDT 2011


Hi,

On Wed, Jun 22, 2011 at 6:30 PM, Alex Flint <alex.flint at 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 at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110622/663f9b1b/attachment.html>


More information about the NumPy-Discussion mailing list