Answers for "how to get index of max n values in an array"

1

how to get index of max n values in an array

In [1]: import numpy as np

In [2]: arr = np.array([1, 3, 2, 4, 5])

In [3]: arr.argsort()[-3:][::-1]
Out[3]: array([4, 3, 1])
Posted by: Guest on July-04-2020

Code answers related to "how to get index of max n values in an array"

Browse Popular Code Answers by Language