Skip to content

Commit aa9a6dc

Browse files
DOC: Fix EX01 in pandas.DataFrame.idxmin (#32697)
1 parent fd2e002 commit aa9a6dc

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

pandas/core/frame.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8020,6 +8020,35 @@ def idxmin(self, axis=0, skipna=True) -> Series:
80208020
Notes
80218021
-----
80228022
This method is the DataFrame version of ``ndarray.argmin``.
8023+
8024+
Examples
8025+
--------
8026+
Consider a dataset containing food consumption in Argentina.
8027+
8028+
>>> df = pd.DataFrame({'consumption': [10.51, 103.11, 55.48],
8029+
... 'co2_emissions': [37.2, 19.66, 1712]},
8030+
... index=['Pork', 'Wheat Products', 'Beef'])
8031+
8032+
>>> df
8033+
consumption co2_emissions
8034+
Pork 10.51 37.20
8035+
Wheat Products 103.11 19.66
8036+
Beef 55.48 1712.00
8037+
8038+
By default, it returns the index for the minimum value in each column.
8039+
8040+
>>> df.idxmin()
8041+
consumption Pork
8042+
co2_emissions Wheat Products
8043+
dtype: object
8044+
8045+
To return the index for the minimum value in each row, use ``axis="columns"``.
8046+
8047+
>>> df.idxmin(axis="columns")
8048+
Pork consumption
8049+
Wheat Products co2_emissions
8050+
Beef consumption
8051+
dtype: object
80238052
"""
80248053
axis = self._get_axis_number(axis)
80258054
indices = nanops.nanargmin(self.values, axis=axis, skipna=skipna)

0 commit comments

Comments
 (0)