@@ -1460,22 +1460,31 @@ def duplicated(self, keep='first'):
1460
1460
1461
1461
def idxmin (self , axis = None , skipna = True , * args , ** kwargs ):
1462
1462
"""
1463
- Index *label* of the first occurrence of minimum of values.
1463
+ Return the row label of the minimum value.
1464
+
1465
+ If multiple values equal the minimum, the first row label with that
1466
+ value is returned.
1464
1467
1465
1468
Parameters
1466
1469
----------
1467
1470
skipna : boolean, default True
1468
1471
Exclude NA/null values. If the entire Series is NA, the result
1469
1472
will be NA.
1473
+ axis : int, default 0
1474
+ For compatibility with DataFrame.idxmin. Redundant for application
1475
+ on Series.
1476
+ *args, **kwargs
1477
+ Additional keywors have no effect but might be accepted
1478
+ for compatibility with NumPy.
1479
+
1480
+ Returns
1481
+ -------
1482
+ idxmin : Index of minimum of values.
1470
1483
1471
1484
Raises
1472
1485
------
1473
1486
ValueError
1474
- * If the Series is empty
1475
-
1476
- Returns
1477
- -------
1478
- idxmin : Index of minimum of values
1487
+ If the Series is empty.
1479
1488
1480
1489
Notes
1481
1490
-----
@@ -1485,33 +1494,66 @@ def idxmin(self, axis=None, skipna=True, *args, **kwargs):
1485
1494
1486
1495
See Also
1487
1496
--------
1488
- DataFrame.idxmin
1489
- numpy.ndarray.argmin
1497
+ numpy.argmin : Return indices of the minimum values
1498
+ along the given axis.
1499
+ DataFrame.idxmin : Return index of first occurrence of minimum
1500
+ over requested axis.
1501
+ Series.idxmax : Return index *label* of the first occurrence
1502
+ of maximum of values.
1503
+
1504
+ Examples
1505
+ --------
1506
+ >>> s = pd.Series(data=[1, None, 4, 1],
1507
+ ... index=['A' ,'B' ,'C' ,'D'])
1508
+ >>> s
1509
+ A 1.0
1510
+ B NaN
1511
+ C 4.0
1512
+ D 1.0
1513
+ dtype: float64
1514
+
1515
+ >>> s.idxmin()
1516
+ 'A'
1517
+
1518
+ If `skipna` is False and there is an NA value in the data,
1519
+ the function returns ``nan``.
1520
+
1521
+ >>> s.idxmin(skipna=False)
1522
+ nan
1490
1523
"""
1491
1524
skipna = nv .validate_argmin_with_skipna (skipna , args , kwargs )
1492
1525
i = nanops .nanargmin (com ._values_from_object (self ), skipna = skipna )
1493
1526
if i == - 1 :
1494
1527
return np .nan
1495
1528
return self .index [i ]
1496
1529
1497
- def idxmax (self , axis = None , skipna = True , * args , ** kwargs ):
1530
+ def idxmax (self , axis = 0 , skipna = True , * args , ** kwargs ):
1498
1531
"""
1499
- Index *label* of the first occurrence of maximum of values.
1532
+ Return the row label of the maximum value.
1533
+
1534
+ If multiple values equal the maximum, the first row label with that
1535
+ value is returned.
1500
1536
1501
1537
Parameters
1502
1538
----------
1503
1539
skipna : boolean, default True
1504
1540
Exclude NA/null values. If the entire Series is NA, the result
1505
1541
will be NA.
1542
+ axis : int, default 0
1543
+ For compatibility with DataFrame.idxmax. Redundant for application
1544
+ on Series.
1545
+ *args, **kwargs
1546
+ Additional keywors have no effect but might be accepted
1547
+ for compatibility with NumPy.
1548
+
1549
+ Returns
1550
+ -------
1551
+ idxmax : Index of maximum of values.
1506
1552
1507
1553
Raises
1508
1554
------
1509
1555
ValueError
1510
- * If the Series is empty
1511
-
1512
- Returns
1513
- -------
1514
- idxmax : Index of maximum of values
1556
+ If the Series is empty.
1515
1557
1516
1558
Notes
1517
1559
-----
@@ -1521,8 +1563,33 @@ def idxmax(self, axis=None, skipna=True, *args, **kwargs):
1521
1563
1522
1564
See Also
1523
1565
--------
1524
- DataFrame.idxmax
1525
- numpy.ndarray.argmax
1566
+ numpy.argmax : Return indices of the maximum values
1567
+ along the given axis.
1568
+ DataFrame.idxmax : Return index of first occurrence of maximum
1569
+ over requested axis.
1570
+ Series.idxmin : Return index *label* of the first occurrence
1571
+ of minimum of values.
1572
+
1573
+ Examples
1574
+ --------
1575
+ >>> s = pd.Series(data=[1, None, 4, 3, 4],
1576
+ ... index=['A', 'B', 'C', 'D', 'E'])
1577
+ >>> s
1578
+ A 1.0
1579
+ B NaN
1580
+ C 4.0
1581
+ D 3.0
1582
+ E 4.0
1583
+ dtype: float64
1584
+
1585
+ >>> s.idxmax()
1586
+ 'C'
1587
+
1588
+ If `skipna` is False and there is an NA value in the data,
1589
+ the function returns ``nan``.
1590
+
1591
+ >>> s.idxmax(skipna=False)
1592
+ nan
1526
1593
"""
1527
1594
skipna = nv .validate_argmax_with_skipna (skipna , args , kwargs )
1528
1595
i = nanops .nanargmax (com ._values_from_object (self ), skipna = skipna )
0 commit comments