Returns the 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. out : array, optional If pr
(a, axis=None, out=None, *, keepdims=np._NoValue)
| 1139 | |
| 1140 | @array_function_dispatch(_argmax_dispatcher) |
| 1141 | def argmax(a, axis=None, out=None, *, keepdims=np._NoValue): |
| 1142 | """ |
| 1143 | Returns the indices of the maximum values along an axis. |
| 1144 | |
| 1145 | Parameters |
| 1146 | ---------- |
| 1147 | a : array_like |
| 1148 | Input array. |
| 1149 | axis : int, optional |
| 1150 | By default, the index is into the flattened array, otherwise |
| 1151 | along the specified axis. |
| 1152 | out : array, optional |
| 1153 | If provided, the result will be inserted into this array. It should |
| 1154 | be of the appropriate shape and dtype. |
| 1155 | keepdims : bool, optional |
| 1156 | If this is set to True, the axes which are reduced are left |
| 1157 | in the result as dimensions with size one. With this option, |
| 1158 | the result will broadcast correctly against the array. |
| 1159 | |
| 1160 | .. versionadded:: 1.22.0 |
| 1161 | |
| 1162 | Returns |
| 1163 | ------- |
| 1164 | index_array : ndarray of ints |
| 1165 | Array of indices into the array. It has the same shape as `a.shape` |
| 1166 | with the dimension along `axis` removed. If `keepdims` is set to True, |
| 1167 | then the size of `axis` will be 1 with the resulting array having same |
| 1168 | shape as `a.shape`. |
| 1169 | |
| 1170 | See Also |
| 1171 | -------- |
| 1172 | ndarray.argmax, argmin |
| 1173 | amax : The maximum value along a given axis. |
| 1174 | unravel_index : Convert a flat index into an index tuple. |
| 1175 | take_along_axis : Apply ``np.expand_dims(index_array, axis)`` |
| 1176 | from argmax to an array as if by calling max. |
| 1177 | |
| 1178 | Notes |
| 1179 | ----- |
| 1180 | In case of multiple occurrences of the maximum values, the indices |
| 1181 | corresponding to the first occurrence are returned. |
| 1182 | |
| 1183 | Examples |
| 1184 | -------- |
| 1185 | >>> a = np.arange(6).reshape(2,3) + 10 |
| 1186 | >>> a |
| 1187 | array([[10, 11, 12], |
| 1188 | [13, 14, 15]]) |
| 1189 | >>> np.argmax(a) |
| 1190 | 5 |
| 1191 | >>> np.argmax(a, axis=0) |
| 1192 | array([1, 1, 1]) |
| 1193 | >>> np.argmax(a, axis=1) |
| 1194 | array([2, 2]) |
| 1195 | |
| 1196 | Indexes of the maximal elements of a N-dimensional array: |
| 1197 | |
| 1198 | >>> ind = np.unravel_index(np.argmax(a, axis=None), a.shape) |
nothing calls this directly
no test coverage detected