-
numpy.argmin(a, axis=None, out=None)
[source] -
Returns the indices of the minimum 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 provided, the result will be inserted into this array. It should be of the appropriate shape and dtype.
Returns: index_array : ndarray of ints
Array of indices into the array. It has the same shape as
a.shape
with the dimension alongaxis
removed.See also
-
amin
- The minimum value along a given axis.
-
unravel_index
- Convert a flat index into an index tuple.
Notes
In case of multiple occurrences of the minimum values, the indices corresponding to the first occurrence are returned.
Examples
12345678910>>> a
=
np.arange(
6
).reshape(
2
,
3
)
>>> a
array([[
0
,
1
,
2
],
[
3
,
4
,
5
]])
>>> np.argmin(a)
0
>>> np.argmin(a, axis
=
0
)
array([
0
,
0
,
0
])
>>> np.argmin(a, axis
=
1
)
array([
0
,
0
])
123456>>> b
=
np.arange(
6
)
>>> b[
4
]
=
0
>>> b
array([
0
,
1
,
2
,
3
,
0
,
5
])
>>> np.argmin(b)
# Only the first occurrence is returned.
0
-
numpy.argmin()

2025-01-10 15:47:30
Please login to continue.