Quantcast
Channel: Get indices of N maximum values in a numpy array without sorting them? - Stack Overflow
Browsing latest articles
Browse All 3 View Live

Answer by Paul Panzer for Get indices of N maximum values in a numpy array...

It probably depends a bit on the sizes of a and k but often the fastest appears to be combining partition with flatnonzero or where:>>> a = np.random.random(10000)>>> k =...

View Article



Answer by AGN Gazer for Get indices of N maximum values in a numpy array...

Use numpy.argpartition():k = 3np.argpartition(arr, len(arr) - k)[-k:]Adjust k index to whatever you need.NOTE: returned indices are not guaranteed to be in the "sorted order" - just that anything past...

View Article

Get indices of N maximum values in a numpy array without sorting them?

My question is very similar to this one: How to get indices of N maximum values in a numpy array?But I would like to get the indices in the same order I find them. Let's take the example marked in that...

View Article
Browsing latest articles
Browse All 3 View Live




Latest Images