@@ -12745,10 +12745,80 @@ def nunique(self, axis: Axis = 0, dropna: bool = True) -> Series:
1274512745 """
1274612746 return self .apply (Series .nunique , axis = axis , dropna = dropna )
1274712747
12748- @doc (_shared_docs ["idxmin" ], numeric_only_default = "False" )
1274912748 def idxmin (
1275012749 self , axis : Axis = 0 , skipna : bool = True , numeric_only : bool = False
1275112750 ) -> Series :
12751+ """
12752+ Return index of first occurrence of minimum over requested axis.
12753+
12754+ NA/null values are excluded.
12755+
12756+ Parameters
12757+ ----------
12758+ axis : {{0 or 'index', 1 or 'columns'}}, default 0
12759+ The axis to use. 0 or 'index' for row-wise, 1 or 'columns' for column-wise.
12760+ skipna : bool, default True
12761+ Exclude NA/null values. If the entire DataFrame is NA,
12762+ or if ``skipna=False`` and there is an NA value, this method
12763+ will raise a ``ValueError``.
12764+ numeric_only : bool, default False
12765+ Include only `float`, `int` or `boolean` data.
12766+
12767+ .. versionadded:: 1.5.0
12768+
12769+ Returns
12770+ -------
12771+ Series
12772+ Indexes of minima along the specified axis.
12773+
12774+ Raises
12775+ ------
12776+ ValueError
12777+ * If the row/column is empty
12778+
12779+ See Also
12780+ --------
12781+ Series.idxmin : Return index of the minimum element.
12782+
12783+ Notes
12784+ -----
12785+ This method is the DataFrame version of ``ndarray.argmin``.
12786+
12787+ Examples
12788+ --------
12789+ Consider a dataset containing food consumption in Argentina.
12790+
12791+ >>> df = pd.DataFrame(
12792+ ... {
12793+ ... {
12794+ ... "consumption": [10.51, 103.11, 55.48],
12795+ ... "co2_emissions": [37.2, 19.66, 1712],
12796+ ... }
12797+ ... },
12798+ ... index=["Pork", "Wheat Products", "Beef"],
12799+ ... )
12800+
12801+ >>> df
12802+ consumption co2_emissions
12803+ Pork 10.51 37.20
12804+ Wheat Products 103.11 19.66
12805+ Beef 55.48 1712.00
12806+
12807+ By default, it returns the index for the minimum value in each column.
12808+
12809+ >>> df.idxmin()
12810+ consumption Pork
12811+ co2_emissions Wheat Products
12812+ dtype: object
12813+
12814+ To return the index for the minimum value in each row, use ``axis="columns"``.
12815+
12816+ >>> df.idxmin(axis="columns")
12817+ Pork consumption
12818+ Wheat Products co2_emissions
12819+ Beef consumption
12820+ dtype: object
12821+ """
1275212822 axis = self ._get_axis_number (axis )
1275312823
1275412824 if self .empty and len (self .axes [axis ]):
@@ -12782,10 +12852,80 @@ def idxmin(
1278212852 final_result = data ._constructor_sliced (result , index = data ._get_agg_axis (axis ))
1278312853 return final_result .__finalize__ (self , method = "idxmin" )
1278412854
12785- @doc (_shared_docs ["idxmax" ], numeric_only_default = "False" )
1278612855 def idxmax (
1278712856 self , axis : Axis = 0 , skipna : bool = True , numeric_only : bool = False
1278812857 ) -> Series :
12858+ """
12859+ Return index of first occurrence of maximum over requested axis.
12860+
12861+ NA/null values are excluded.
12862+
12863+ Parameters
12864+ ----------
12865+ axis : {{0 or 'index', 1 or 'columns'}}, default 0
12866+ The axis to use. 0 or 'index' for row-wise, 1 or 'columns' for column-wise.
12867+ skipna : bool, default True
12868+ Exclude NA/null values. If the entire DataFrame is NA,
12869+ or if ``skipna=False`` and there is an NA value, this method
12870+ will raise a ``ValueError``.
12871+ numeric_only : bool, default False
12872+ Include only `float`, `int` or `boolean` data.
12873+
12874+ .. versionadded:: 1.5.0
12875+
12876+ Returns
12877+ -------
12878+ Series
12879+ Indexes of maxima along the specified axis.
12880+
12881+ Raises
12882+ ------
12883+ ValueError
12884+ * If the row/column is empty
12885+
12886+ See Also
12887+ --------
12888+ Series.idxmax : Return index of the maximum element.
12889+
12890+ Notes
12891+ -----
12892+ This method is the DataFrame version of ``ndarray.argmax``.
12893+
12894+ Examples
12895+ --------
12896+ Consider a dataset containing food consumption in Argentina.
12897+
12898+ >>> df = pd.DataFrame(
12899+ ... {
12900+ ... {
12901+ ... "consumption": [10.51, 103.11, 55.48],
12902+ ... "co2_emissions": [37.2, 19.66, 1712],
12903+ ... }
12904+ ... },
12905+ ... index=["Pork", "Wheat Products", "Beef"],
12906+ ... )
12907+
12908+ >>> df
12909+ consumption co2_emissions
12910+ Pork 10.51 37.20
12911+ Wheat Products 103.11 19.66
12912+ Beef 55.48 1712.00
12913+
12914+ By default, it returns the index for the maximum value in each column.
12915+
12916+ >>> df.idxmax()
12917+ consumption Wheat Products
12918+ co2_emissions Beef
12919+ dtype: object
12920+
12921+ To return the index for the maximum value in each row, use ``axis="columns"``.
12922+
12923+ >>> df.idxmax(axis="columns")
12924+ Pork co2_emissions
12925+ Wheat Products consumption
12926+ Beef co2_emissions
12927+ dtype: object
12928+ """
1278912929 axis = self ._get_axis_number (axis )
1279012930
1279112931 if self .empty and len (self .axes [axis ]):
0 commit comments