>>> a.argmax(axis=0)
array([1, 1, 0])
Answer from eumiro on Stack OverflowNumPy
numpy.org โบ doc โบ stable โบ reference โบ generated โบ numpy.argmax.html
numpy.argmax โ NumPy v2.5 Manual
Returns the indices of the maximum values along an axis. ... Input array. ... By default, the index is into the flattened array, otherwise along the specified axis.
DataCamp
datacamp.com โบ doc โบ numpy โบ argmax
NumPy argmax()
NumPy's `argmax()` function is used in array computation and analysis to find the index of the maximum value within an array.
03:11
NumPy argmax() Tutorial: Find Index of Maximum Value in Arrays ...
03:11
numpy max index - YouTube
how to find index of max value in numpy array
01:47
How to Index Each Occurrence of a Max Value along a Given Axis ...
03:17
How do I get indices of N maximum values in a NumPy array? - YouTube
00:49
Find the Index of the Biggest and Smallest Element of a #numpy ...
NumPy
numpy.org โบ doc โบ 2.2 โบ reference โบ generated โบ numpy.argmax.html
numpy.argmax โ NumPy v2.2 Manual
Returns the indices of the maximum values along an axis. ... Input array. ... By default, the index is into the flattened array, otherwise along the specified axis.
NumPy
numpy.org โบ doc โบ 2.0 โบ reference โบ generated โบ numpy.argmax.html
numpy.argmax โ NumPy v2.0 Manual
Returns the indices of the maximum values along an axis. ... Input array. ... By default, the index is into the flattened array, otherwise along the specified axis.
Educative
educative.io โบ answers โบ how-to-get-indices-of-n-maximum-values-in-numpy-arrays
How to get indices of N maximum values in NumPy arrays
In order to get the indices of N maximum values in a NumPy array, we can use the argsort() function.
Real Python
realpython.com โบ numpy-max-maximum
NumPy's max() and maximum(): Find Extreme Values in Arrays โ Real Python
October 22, 2025 - In this introduction to NumPy, you'll learn how to find extreme values using the max() and maximum() functions. This includes finding the maximum element in an array or along a given axis of an array, as well as comparing two arrays to find the larger element in each index position.
Top answer 1 of 16
1032
Newer NumPy versions (1.8 and up) have a function called argpartition for this. To get the indices of the four largest elements, do
>>> a = np.array([9, 4, 4, 3, 3, 9, 0, 4, 6, 0])
>>> a
array([9, 4, 4, 3, 3, 9, 0, 4, 6, 0])
>>> ind = np.argpartition(a, -4)[-4:]
>>> ind
array([1, 5, 8, 0])
>>> top4 = a[ind]
>>> top4
array([4, 9, 6, 9])
Unlike argsort, this function runs in linear time in the worst case, but the returned indices are not sorted, as can be seen from the result of evaluating a[ind]. If you need that too, sort them afterwards:
>>> ind[np.argsort(a[ind])]
array([1, 8, 5, 0])
To get the top-k elements in sorted order in this way takes O(n + k log k) time.
2 of 16
521
The simplest I've been able to come up with is:
>>> import numpy as np
>>> arr = np.array([1, 3, 2, 4, 5])
>>> arr.argsort()[-3:][::-1]
array([4, 3, 1])
This involves a complete sort of the array. I wonder if numpy provides a built-in way to do a partial sort; so far I haven't been able to find one.
If this solution turns out to be too slow (especially for small n), it may be worth looking at coding something up in Cython.
Programiz
programiz.com โบ python-programming โบ numpy โบ methods โบ argmax
NumPy argmax()
import numpy as np array1 = np.array([10, 12, 14, 11, 5]) # return index of largest element (14) maxIndex= np.argmax(array1) print(maxIndex) # Output: 2
NumPy
numpy.org โบ devdocs โบ reference โบ generated โบ numpy.argmax.html
numpy.argmax โ NumPy v2.6.dev0 Manual
Returns the indices of the maximum values along an axis. ... Input array. ... By default, the index is into the flattened array, otherwise along the specified axis.
NumPy
numpy.org โบ doc โบ 2.3 โบ reference โบ generated โบ numpy.argmax.html
numpy.argmax โ NumPy v2.3 Manual
Returns the indices of the maximum values along an axis. ... Input array. ... By default, the index is into the flattened array, otherwise along the specified axis.
Codecademy
codecademy.com โบ docs โบ python:numpy โบ ndarray โบ .argmax()
Python:NumPy | ndarray | .argmax() | Codecademy
October 31, 2025 - Returns the indices of the maximum values along a specified axis.
Omz Software
omz-software.com โบ pythonista โบ numpy โบ reference โบ generated โบ numpy.argmax.html
numpy.argmax โ NumPy v1.8 Manual
Indices of the maximum values along an axis.