pandas 1.4.2

NotesParametersRaisesReturnsBackRef
idxmin(self, axis: 'Axis' = 0, skipna: 'bool' = True) -> 'Series'

NA/null values are excluded.

Notes

This method is the DataFrame version of ndarray.argmin .

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.

skipna : bool, default True

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

Raises

ValueError
  • If the row/column is empty

Returns

Series

Indexes of minima along the specified axis.

Return index of first occurrence of minimum over requested axis.

See Also

Series.idxmin

Return index of the minimum element.

Examples

Consider a dataset containing food consumption in Argentina.

This example is valid syntax, but we were not able to check execution
>>> df = pd.DataFrame({'consumption': [10.51, 103.11, 55.48],
...  'co2_emissions': [37.2, 19.66, 1712]},
...  index=['Pork', 'Wheat Products', 'Beef'])
This example is valid syntax, but we were not able to check execution
>>> 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.

This example is valid syntax, but we were not able to check execution
>>> df.idxmin()
consumption                Pork
co2_emissions    Wheat Products
dtype: object

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

This example is valid syntax, but we were not able to check execution
>>> df.idxmin(axis="columns")
Pork                consumption
Wheat Products    co2_emissions
Beef                consumption
dtype: object
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

pandas.core.series.Series.idxmin pandas.core.generic.NDFrame._add_numeric_operations.<locals>.min pandas.core.generic.NDFrame._add_numeric_operations.<locals>.prod pandas.core.generic.NDFrame._add_numeric_operations.<locals>.sum pandas.core.generic.NDFrame._add_numeric_operations.<locals>.max

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/frame.py#10151
type: <class 'function'>
Commit: