numpy.argmax

numpy.argmax(a, axis=None)

Indices of the maximum values along an axis.

Parameters:

a : array_like

Input array.

axis : int, optional

By default, the index is into the flattened array, otherwise along the specified axis.

Returns:

index_array : ndarray, int

Array of indices into the array. It has the same shape as a, except with axis removed.

See also

argmin
Indices of the minimum values along an axis.
amax
The maximum value along a given axis.
unravel_index
Convert a flat index into an index tuple.

Examples

>>> a = np.arange(6).reshape(2,3)
>>> np.argmax(a)
5
>>> np.argmax(a, axis=0)
array([1, 1, 1])
>>> np.argmax(a, axis=1)
array([2, 2])

Previous topic

numpy.sort_complex

Next topic

numpy.nanargmax

This Page

Quick search