Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.DataFrame.idxmin#

DataFrame.idxmin(axis=0,skipna=True,numeric_only=False)[source]#

Return index of first occurrence of minimum over requested axis.

NA/null values are excluded.

Parameters:
axis{0 or ‘index’, 1 or ‘columns’}, default 0

The axis to use. 0 or ‘index’ for row-wise, 1 or ‘columns’ for column-wise.

skipnabool, default True

Exclude NA/null values. If an entire row/column is NA, the resultwill be NA.

numeric_onlybool, default False

Include onlyfloat,int orboolean data.

Added in version 1.5.0.

Returns:
Series

Indexes of minima along the specified axis.

Raises:
ValueError
  • If the row/column is empty

See also

Series.idxmin

Return index of the minimum element.

Notes

This method is the DataFrame version ofndarray.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_emissionsPork                  10.51         37.20Wheat Products       103.11         19.66Beef                  55.48       1712.00

By default, it returns the index for the minimum value in each column.

>>>df.idxmin()consumption                Porkco2_emissions    Wheat Productsdtype: object

To return the index for the minimum value in each row, useaxis="columns".

>>>df.idxmin(axis="columns")Pork                consumptionWheat Products    co2_emissionsBeef                consumptiondtype: object

[8]ページ先頭

©2009-2025 Movatter.jp