Skip to content

Commit 293b16d

Browse files
committed
Merge pull request #3580 from cpcloud/argminmax-doc-3574
DOC: add mention of idx* methods in max/min methods of Series/DataFrame
2 parents d9dc1cb + 6e8e4a0 commit 293b16d

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

doc/source/basics.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,10 @@ value, ``idxmin`` and ``idxmax`` return the first matching index:
401401
df3
402402
df3['A'].idxmin()
403403
404+
.. note::
405+
406+
``idxmin`` and ``idxmax`` are called ``argmin`` and ``argmax`` in NumPy.
407+
404408
.. _basics.discretization:
405409

406410
Value counts (histogramming)

pandas/core/frame.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4770,6 +4770,18 @@ def mean(self, axis=0, skipna=True, level=None):
47704770
extras='')
47714771
@Appender(_stat_doc)
47724772
def min(self, axis=0, skipna=True, level=None):
4773+
"""
4774+
Notes
4775+
-----
4776+
This method returns the minimum of the values in the DataFrame. If you
4777+
want the *index* of the minimum, use ``DataFrame.idxmin``. This is the
4778+
equivalent of the ``numpy.ndarray`` method ``argmin``.
4779+
4780+
See Also
4781+
--------
4782+
DataFrame.idxmin
4783+
Series.idxmin
4784+
"""
47734785
if level is not None:
47744786
return self._agg_by_level('min', axis=axis, level=level,
47754787
skipna=skipna)
@@ -4780,6 +4792,18 @@ def min(self, axis=0, skipna=True, level=None):
47804792
extras='')
47814793
@Appender(_stat_doc)
47824794
def max(self, axis=0, skipna=True, level=None):
4795+
"""
4796+
Notes
4797+
-----
4798+
This method returns the maximum of the values in the DataFrame. If you
4799+
want the *index* of the maximum, use ``DataFrame.idxmax``. This is the
4800+
equivalent of the ``numpy.ndarray`` method ``argmax``.
4801+
4802+
See Also
4803+
--------
4804+
DataFrame.idxmax
4805+
Series.idxmax
4806+
"""
47834807
if level is not None:
47844808
return self._agg_by_level('max', axis=axis, level=level,
47854809
skipna=skipna)
@@ -4939,6 +4963,14 @@ def idxmin(self, axis=0, skipna=True):
49394963
Returns
49404964
-------
49414965
idxmin : Series
4966+
4967+
Notes
4968+
-----
4969+
This method is the DataFrame version of ``ndarray.argmin``.
4970+
4971+
See Also
4972+
--------
4973+
Series.idxmin
49424974
"""
49434975
axis = self._get_axis_number(axis)
49444976
indices = nanops.nanargmin(self.values, axis=axis, skipna=skipna)
@@ -4962,6 +4994,14 @@ def idxmax(self, axis=0, skipna=True):
49624994
Returns
49634995
-------
49644996
idxmax : Series
4997+
4998+
Notes
4999+
-----
5000+
This method is the DataFrame version of ``ndarray.argmax``.
5001+
5002+
See Also
5003+
--------
5004+
Series.idxmax
49655005
"""
49665006
axis = self._get_axis_number(axis)
49675007
indices = nanops.nanargmax(self.values, axis=axis, skipna=skipna)

pandas/core/series.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,18 @@ def mad(self, skipna=True, level=None):
15161516
na_action=_doc_exclude_na, extras='')
15171517
@Appender(_stat_doc)
15181518
def min(self, axis=None, out=None, skipna=True, level=None):
1519+
"""
1520+
Notes
1521+
-----
1522+
This method returns the minimum of the values in the Series. If you
1523+
want the *index* of the minimum, use ``Series.idxmin``. This is the
1524+
equivalent of the ``numpy.ndarray`` method ``argmin``.
1525+
1526+
See Also
1527+
--------
1528+
Series.idxmin
1529+
DataFrame.idxmin
1530+
"""
15191531
if level is not None:
15201532
return self._agg_by_level('min', level=level, skipna=skipna)
15211533
return nanops.nanmin(self.values, skipna=skipna)
@@ -1524,6 +1536,18 @@ def min(self, axis=None, out=None, skipna=True, level=None):
15241536
na_action=_doc_exclude_na, extras='')
15251537
@Appender(_stat_doc)
15261538
def max(self, axis=None, out=None, skipna=True, level=None):
1539+
"""
1540+
Notes
1541+
-----
1542+
This method returns the maximum of the values in the Series. If you
1543+
want the *index* of the maximum, use ``Series.idxmax``. This is the
1544+
equivalent of the ``numpy.ndarray`` method ``argmax``.
1545+
1546+
See Also
1547+
--------
1548+
Series.idxmax
1549+
DataFrame.idxmax
1550+
"""
15271551
if level is not None:
15281552
return self._agg_by_level('max', level=level, skipna=skipna)
15291553
return nanops.nanmax(self.values, skipna=skipna)
@@ -1592,6 +1616,14 @@ def idxmin(self, axis=None, out=None, skipna=True):
15921616
Returns
15931617
-------
15941618
idxmin : Index of minimum of values
1619+
1620+
Notes
1621+
-----
1622+
This method is the Series version of ``ndarray.argmin``.
1623+
1624+
See Also
1625+
--------
1626+
DataFrame.idxmin
15951627
"""
15961628
i = nanops.nanargmin(self.values, skipna=skipna)
15971629
if i == -1:
@@ -1610,6 +1642,14 @@ def idxmax(self, axis=None, out=None, skipna=True):
16101642
Returns
16111643
-------
16121644
idxmax : Index of minimum of values
1645+
1646+
Notes
1647+
-----
1648+
This method is the Series version of ``ndarray.argmax``.
1649+
1650+
See Also
1651+
--------
1652+
DataFrame.idxmax
16131653
"""
16141654
i = nanops.nanargmax(self.values, skipna=skipna)
16151655
if i == -1:

0 commit comments

Comments
 (0)