@@ -1321,8 +1321,8 @@ def idxmin(self, skipna: bool = True) -> Series:
1321
1321
1322
1322
Returns
1323
1323
-------
1324
- Index
1325
- Label of the minimum value .
1324
+ Series
1325
+ Indexes of minima in each group .
1326
1326
1327
1327
Raises
1328
1328
------
@@ -1374,8 +1374,8 @@ def idxmax(self, skipna: bool = True) -> Series:
1374
1374
1375
1375
Returns
1376
1376
-------
1377
- Index
1378
- Label of the maximum value .
1377
+ Series
1378
+ Indexes of maxima in each group .
1379
1379
1380
1380
Raises
1381
1381
------
@@ -2512,8 +2512,8 @@ def idxmax(
2512
2512
2513
2513
Returns
2514
2514
-------
2515
- Series
2516
- Indexes of maxima in each group.
2515
+ DataFrame
2516
+ Indexes of maxima in each column according to the group.
2517
2517
2518
2518
Raises
2519
2519
------
@@ -2523,6 +2523,7 @@ def idxmax(
2523
2523
See Also
2524
2524
--------
2525
2525
Series.idxmax : Return index of the maximum element.
2526
+ DataFrame.idxmax : Indexes of maxima along the specified axis.
2526
2527
2527
2528
Notes
2528
2529
-----
@@ -2536,6 +2537,7 @@ def idxmax(
2536
2537
... {
2537
2538
... "consumption": [10.51, 103.11, 55.48],
2538
2539
... "co2_emissions": [37.2, 19.66, 1712],
2540
+ ... "food_type": ["meat", "plant", "meat"],
2539
2541
... },
2540
2542
... index=["Pork", "Wheat Products", "Beef"],
2541
2543
... )
@@ -2546,12 +2548,14 @@ def idxmax(
2546
2548
Wheat Products 103.11 19.66
2547
2549
Beef 55.48 1712.00
2548
2550
2549
- 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.
2550
2553
2551
- >>> df.idxmax()
2552
- consumption Wheat Products
2553
- co2_emissions Beef
2554
- 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
2555
2559
"""
2556
2560
return self ._idxmax_idxmin ("idxmax" , numeric_only = numeric_only , skipna = skipna )
2557
2561
@@ -2574,8 +2578,8 @@ def idxmin(
2574
2578
2575
2579
Returns
2576
2580
-------
2577
- Series
2578
- Indexes of minima in each group.
2581
+ DataFrame
2582
+ Indexes of minima in each column according to the group.
2579
2583
2580
2584
Raises
2581
2585
------
@@ -2585,6 +2589,7 @@ def idxmin(
2585
2589
See Also
2586
2590
--------
2587
2591
Series.idxmin : Return index of the minimum element.
2592
+ DataFrame.idxmin : Indexes of minima along the specified axis.
2588
2593
2589
2594
Notes
2590
2595
-----
@@ -2598,6 +2603,7 @@ def idxmin(
2598
2603
... {
2599
2604
... "consumption": [10.51, 103.11, 55.48],
2600
2605
... "co2_emissions": [37.2, 19.66, 1712],
2606
+ ... "food_type": ["meat", "plant", "meat"],
2601
2607
... },
2602
2608
... index=["Pork", "Wheat Products", "Beef"],
2603
2609
... )
@@ -2608,12 +2614,14 @@ def idxmin(
2608
2614
Wheat Products 103.11 19.66
2609
2615
Beef 55.48 1712.00
2610
2616
2611
- 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.
2612
2619
2613
- >>> df.idxmin()
2614
- consumption Pork
2615
- co2_emissions Wheat Products
2616
- 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
2617
2625
"""
2618
2626
return self ._idxmax_idxmin ("idxmin" , numeric_only = numeric_only , skipna = skipna )
2619
2627
0 commit comments