• Home
  • Recent Q&A
  • Java
  • Cloud
  • JavaScript
  • Python
  • SQL
  • PHP
  • HTML
  • C++
  • Data Science
  • DBMS
  • Devops
  • Hadoop
  • Machine Learning
in Python by
Q:
Write a program in Python for getting indices of N maximum values in a NumPy array.

1 Answer

0 votes
by
import numpy as np

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

print(arr.argsort()[-3:][::-1])

Output:

[4 3 1]

Related questions

+2 votes
asked Jul 4, 2021 in NumPy by sharadyadav1986
0 votes
asked May 17, 2020 in Python by SakshiSharma
...