Skip to content

DOC: add mention of idx* methods in max/min methods of Series/DataFrame #3580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 13, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/source/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,10 @@ value, ``idxmin`` and ``idxmax`` return the first matching index:
df3
df3['A'].idxmin()

.. note::

``idxmin`` and ``idxmax`` are called ``argmin`` and ``argmax`` in NumPy.

.. _basics.discretization:

Value counts (histogramming)
Expand Down
40 changes: 40 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4770,6 +4770,18 @@ def mean(self, axis=0, skipna=True, level=None):
extras='')
@Appender(_stat_doc)
def min(self, axis=0, skipna=True, level=None):
"""
Notes
-----
This method returns the minimum of the values in the DataFrame. If you
want the *index* of the minimum, use ``DataFrame.idxmin``. This is the
equivalent of the ``numpy.ndarray`` method ``argmin``.

See Also
--------
DataFrame.idxmin
Series.idxmin
"""
if level is not None:
return self._agg_by_level('min', axis=axis, level=level,
skipna=skipna)
Expand All @@ -4780,6 +4792,18 @@ def min(self, axis=0, skipna=True, level=None):
extras='')
@Appender(_stat_doc)
def max(self, axis=0, skipna=True, level=None):
"""
Notes
-----
This method returns the maximum of the values in the DataFrame. If you
want the *index* of the maximum, use ``DataFrame.idxmax``. This is the
equivalent of the ``numpy.ndarray`` method ``argmax``.

See Also
--------
DataFrame.idxmax
Series.idxmax
"""
if level is not None:
return self._agg_by_level('max', axis=axis, level=level,
skipna=skipna)
Expand Down Expand Up @@ -4939,6 +4963,14 @@ def idxmin(self, axis=0, skipna=True):
Returns
-------
idxmin : Series

Notes
-----
This method is the DataFrame version of ``ndarray.argmin``.

See Also
--------
Series.idxmin
"""
axis = self._get_axis_number(axis)
indices = nanops.nanargmin(self.values, axis=axis, skipna=skipna)
Expand All @@ -4962,6 +4994,14 @@ def idxmax(self, axis=0, skipna=True):
Returns
-------
idxmax : Series

Notes
-----
This method is the DataFrame version of ``ndarray.argmax``.

See Also
--------
Series.idxmax
"""
axis = self._get_axis_number(axis)
indices = nanops.nanargmax(self.values, axis=axis, skipna=skipna)
Expand Down
40 changes: 40 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,18 @@ def mad(self, skipna=True, level=None):
na_action=_doc_exclude_na, extras='')
@Appender(_stat_doc)
def min(self, axis=None, out=None, skipna=True, level=None):
"""
Notes
-----
This method returns the minimum of the values in the Series. If you
want the *index* of the minimum, use ``Series.idxmin``. This is the
equivalent of the ``numpy.ndarray`` method ``argmin``.

See Also
--------
Series.idxmin
DataFrame.idxmin
"""
if level is not None:
return self._agg_by_level('min', level=level, skipna=skipna)
return nanops.nanmin(self.values, skipna=skipna)
Expand All @@ -1524,6 +1536,18 @@ def min(self, axis=None, out=None, skipna=True, level=None):
na_action=_doc_exclude_na, extras='')
@Appender(_stat_doc)
def max(self, axis=None, out=None, skipna=True, level=None):
"""
Notes
-----
This method returns the maximum of the values in the Series. If you
want the *index* of the maximum, use ``Series.idxmax``. This is the
equivalent of the ``numpy.ndarray`` method ``argmax``.

See Also
--------
Series.idxmax
DataFrame.idxmax
"""
if level is not None:
return self._agg_by_level('max', level=level, skipna=skipna)
return nanops.nanmax(self.values, skipna=skipna)
Expand Down Expand Up @@ -1592,6 +1616,14 @@ def idxmin(self, axis=None, out=None, skipna=True):
Returns
-------
idxmin : Index of minimum of values

Notes
-----
This method is the Series version of ``ndarray.argmin``.

See Also
--------
DataFrame.idxmin
"""
i = nanops.nanargmin(self.values, skipna=skipna)
if i == -1:
Expand All @@ -1610,6 +1642,14 @@ def idxmax(self, axis=None, out=None, skipna=True):
Returns
-------
idxmax : Index of minimum of values

Notes
-----
This method is the Series version of ``ndarray.argmax``.

See Also
--------
DataFrame.idxmax
"""
i = nanops.nanargmax(self.values, skipna=skipna)
if i == -1:
Expand Down