numpy.argmax(a,axis=None,out=None)[source]¶Returns the indices of the maximum values along an axis.
| Parameters: |
|
|---|---|
| Returns: |
|
See also
amaxunravel_indexNotes
In case of multiple occurrences of the maximum values, the indicescorresponding to the first occurrence are returned.
Examples
>>>a=np.arange(6).reshape(2,3)>>>aarray([[0, 1, 2], [3, 4, 5]])>>>np.argmax(a)5>>>np.argmax(a,axis=0)array([1, 1, 1])>>>np.argmax(a,axis=1)array([2, 2])
Indexes of the maximal elements of a N-dimensional array:
>>>ind=np.unravel_index(np.argmax(a,axis=None),a.shape)>>>ind(1, 2)>>>a[ind]5
>>>b=np.arange(6)>>>b[1]=5>>>barray([0, 5, 2, 3, 4, 5])>>>np.argmax(b)# Only the first occurrence is returned.1