Quantcast
Viewing latest article 8
Browse Latest Browse All 8

A fast way to find the largest N elements in an numpy array

I know I can do it like the following:

import numpy as npN=10a=np.arange(1,100,1)np.argsort()[-N:]

However, it is very slow since it did a full sort.

I wonder whether numpy provide some methods the do it fast.


Viewing latest article 8
Browse Latest Browse All 8

Trending Articles