Return index of first occurrence of minimum over requested axis.
NA/null values are excluded.
The axis to use. 0 or ‘index’ for row-wise, 1 or ‘columns’ for column-wise. If axis is not provided, grouper’s axis is used.
Changed in version 2.0.0.
Deprecated since version 2.1.0: For axis=1, operate on the underlying object instead. Otherwise the axis keyword is not necessary.
Exclude NA/null values. If an entire row/column is NA, the result will be NA.
Include only float, int or boolean data.
Added in version 1.5.0.
Indexes of minima along the specified axis.
If the row/column is empty
See also
Series.idxminReturn index of the minimum element.
Notes
This method is the DataFrame version of ndarray.argmin.
Examples
Consider a dataset containing food consumption in Argentina.
>>> df = pd.DataFrame({'consumption': [10.51, 103.11, 55.48],
... 'co2_emissions': [37.2, 19.66, 1712]},
... index=['Pork', 'Wheat Products', 'Beef'])
>>> df
consumption co2_emissions
Pork 10.51 37.20
Wheat Products 103.11 19.66
Beef 55.48 1712.00
By default, it returns the index for the minimum value in each column.
>>> df.idxmin()
consumption Pork
co2_emissions Wheat Products
dtype: object
To return the index for the minimum value in each row, use axis="columns".
>>> df.idxmin(axis="columns")
Pork consumption
Wheat Products co2_emissions
Beef consumption
dtype: object
© 2008–2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
© 2011–2025, Open source contributors
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.3.0/reference/api/pandas.core.groupby.DataFrameGroupBy.idxmin.html