argmin(a, axis=None, out=None)[source]¶
Returns the indices of the minimum values along an axis.
- a : array_like
- axis : int, optional
By default, the index is into the flattened array, otherwise along the specified axis.
- out : array, optional
If provided, the result will be inserted into this array. It should be of the appropriate shape and dtype.
- index_array : ndarray of ints
Array of indices into the array. It has the same shape as a.shape with the dimension along axis removed.
- The minimum value along a given axis.
- Convert a flat index into an index tuple.
In case of multiple occurrences of the minimum values, the indices corresponding to the first occurrence are returned.
>>> a = np.arange(6).reshape(2,3) + 10 >>> a array([[10, 11, 12], [13, 14, 15]]) >>> np.argmin(a) 0 >>> np.argmin(a, axis=0) array([0, 0, 0]) >>> np.argmin(a, axis=1) array([0, 0])
Indices of the minimum elements of a N-dimensional array:
>>> ind = np.unravel_index(np.argmin(a, axis=None), a.shape) >>> ind (0, 0) >>> a[ind] 10
>>> b = np.arange(6) + 10 >>> b = 10 >>> b array([10, 11, 12, 13, 10, 15]) >>> np.argmin(b) # Only the first occurrence is returned. 0