@@ -1321,8 +1321,8 @@ def idxmin(self, skipna: bool = True) -> Series:
13211321
13221322 Returns
13231323 -------
1324- Index
1325- Label of the minimum value .
1324+ Series
1325+ Indexes of minima in each group .
13261326
13271327 Raises
13281328 ------
@@ -1374,8 +1374,8 @@ def idxmax(self, skipna: bool = True) -> Series:
13741374
13751375 Returns
13761376 -------
1377- Index
1378- Label of the maximum value .
1377+ Series
1378+ Indexes of maxima in each group .
13791379
13801380 Raises
13811381 ------
@@ -2453,6 +2453,10 @@ def nunique(self, dropna: bool = True) -> DataFrame:
24532453 nunique: DataFrame
24542454 Counts of unique elements in each position.
24552455
2456+ See Also
2457+ --------
2458+ DataFrame.nunique : Count number of distinct elements in specified axis.
2459+
24562460 Examples
24572461 --------
24582462 >>> df = pd.DataFrame(
@@ -2508,8 +2512,8 @@ def idxmax(
25082512
25092513 Returns
25102514 -------
2511- Series
2512- Indexes of maxima in each group.
2515+ DataFrame
2516+ Indexes of maxima in each column according to the group.
25132517
25142518 Raises
25152519 ------
@@ -2519,6 +2523,7 @@ def idxmax(
25192523 See Also
25202524 --------
25212525 Series.idxmax : Return index of the maximum element.
2526+ DataFrame.idxmax : Indexes of maxima along the specified axis.
25222527
25232528 Notes
25242529 -----
@@ -2532,6 +2537,7 @@ def idxmax(
25322537 ... {
25332538 ... "consumption": [10.51, 103.11, 55.48],
25342539 ... "co2_emissions": [37.2, 19.66, 1712],
2540+ ... "food_type": ["meat", "plant", "meat"],
25352541 ... },
25362542 ... index=["Pork", "Wheat Products", "Beef"],
25372543 ... )
@@ -2542,12 +2548,14 @@ def idxmax(
25422548 Wheat Products 103.11 19.66
25432549 Beef 55.48 1712.00
25442550
2545- By default, it returns the index for the maximum value in each column.
2551+ By default, it returns the index for the maximum value in each column
2552+ according to the group.
25462553
2547- >>> df.idxmax()
2548- consumption Wheat Products
2549- co2_emissions Beef
2550- dtype: object
2554+ >>> df.groupby("food_type").idxmax()
2555+ consumption co2_emissions
2556+ food_type
2557+ animal Beef Beef
2558+ plant Wheat Products Wheat Products
25512559 """
25522560 return self ._idxmax_idxmin ("idxmax" , numeric_only = numeric_only , skipna = skipna )
25532561
@@ -2570,8 +2578,8 @@ def idxmin(
25702578
25712579 Returns
25722580 -------
2573- Series
2574- Indexes of minima in each group.
2581+ DataFrame
2582+ Indexes of minima in each column according to the group.
25752583
25762584 Raises
25772585 ------
@@ -2581,6 +2589,7 @@ def idxmin(
25812589 See Also
25822590 --------
25832591 Series.idxmin : Return index of the minimum element.
2592+ DataFrame.idxmin : Indexes of minima along the specified axis.
25842593
25852594 Notes
25862595 -----
@@ -2594,6 +2603,7 @@ def idxmin(
25942603 ... {
25952604 ... "consumption": [10.51, 103.11, 55.48],
25962605 ... "co2_emissions": [37.2, 19.66, 1712],
2606+ ... "food_type": ["meat", "plant", "meat"],
25972607 ... },
25982608 ... index=["Pork", "Wheat Products", "Beef"],
25992609 ... )
@@ -2604,12 +2614,14 @@ def idxmin(
26042614 Wheat Products 103.11 19.66
26052615 Beef 55.48 1712.00
26062616
2607- By default, it returns the index for the minimum value in each column.
2617+ By default, it returns the index for the minimum value in each column
2618+ according to the group.
26082619
2609- >>> df.idxmin()
2610- consumption Pork
2611- co2_emissions Wheat Products
2612- dtype: object
2620+ >>> df.groupby("food_type").idxmin()
2621+ consumption co2_emissions
2622+ food_type
2623+ animal Pork Pork
2624+ plant Wheat Products Wheat Products
26132625 """
26142626 return self ._idxmax_idxmin ("idxmin" , numeric_only = numeric_only , skipna = skipna )
26152627
0 commit comments