How to get indices of n maximum values in a numpy array?
Answer / Alka Rani
To get the indices of n maximum values in a NumPy array, you can use the 'argsort' method. Here is an example: arr = np.array([1, 5, -3, 6, 2]); indices = np.argpartition(arr, n=n)[:n]; max_values = arr[indices]
| Is This Answer Correct ? | 0 Yes | 0 No |
Is there a null in python?
What is zip() function in python?
What does all do in python?
What are the immutable build-in data types of python?
How do I run python?
What is the difference between uuid and guid?
Explain split(), sub(), sub() methods of “re” module in python?
Which compiler is best for python?
How to use the slicing operator in Python?
What does == mean?
What is range() in python?
Can I make games with python?