The Python Oracle

How do I get indices of N maximum values in a NumPy array?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Cool Puzzler LoFi

--

Chapters
00:00 Question
00:45 Accepted answer (Score 929)
01:34 Answer 2 (Score 494)
02:09 Answer 3 (Score 77)
02:25 Answer 4 (Score 50)
02:55 Thank you

--

Full question
https://stackoverflow.com/questions/6910...

Question links:
[np.argmax]: https://numpy.org/doc/stable/reference/g...

Accepted answer links:
[argpartition]: http://docs.scipy.org/doc/numpy/referenc...
[argsort]: http://docs.scipy.org/doc/numpy/referenc...

Answer 2 links:
[Cython]: http://cython.org/

Answer 4 links:
[heapq — Heap queue algorithm]: http://docs.python.org/3/library/heapq.h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #numpy #max #numpyndarray

#avk47