Series.
idxmin
Return the row label of the minimum value.
If multiple values equal the minimum, the first row label with that value is returned.
Exclude NA/null values. If the entire Series is NA, the result will be NA.
Label of the minimum value.
If the Series is empty.
See also
Series.idxmax
Return index label of the first occurrence of maximum of values.
Notes
This method is the Series version of ndarray.argmin. This method returns the label of the minimum, while ndarray.argmin returns the position. To get the position, use series.values.argmin().
ndarray.argmin
series.values.argmin()
Examples
>>> s = ps.Series(data=[1, None, 4, 0], ... index=['A', 'B', 'C', 'D']) >>> s A 1.0 B NaN C 4.0 D 0.0 dtype: float64
>>> s.idxmin() 'D'
If skipna is False and there is an NA value in the data, the function returns nan.
nan
>>> s.idxmin(skipna=False) nan
In case of multi-index, you get a tuple:
>>> index = pd.MultiIndex.from_arrays([ ... ['a', 'a', 'b', 'b'], ['c', 'd', 'e', 'f']], names=('first', 'second')) >>> s = ps.Series(data=[1, None, 4, 0], index=index) >>> s first second a c 1.0 d NaN b e 4.0 f 0.0 dtype: float64
>>> s.idxmin() ('b', 'f')
>>> s = ps.Series([1, 100, 1, 100, 1, 100], index=[10, 3, 5, 2, 1, 8]) >>> s 10 1 3 100 5 1 2 100 1 1 8 100 dtype: int64
>>> s.idxmin() 10