Skip to content

DOC: Update Series min and max docstring. GH22459 #22554

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

Closed
wants to merge 12 commits into from
66 changes: 45 additions & 21 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9589,7 +9589,7 @@ def _add_numeric_operations(cls):
desc="Return the mean absolute deviation of the values "
"for the requested axis",
name1=name, name2=name2, axis_descr=axis_descr,
min_count='', examples='')
min_count='', see_also='', examples='')
@Appender(_num_doc)
def mad(self, axis=None, skipna=None, level=None):
if skipna is None:
Expand Down Expand Up @@ -9630,8 +9630,8 @@ def mad(self, axis=None, skipna=None, level=None):
@Substitution(outname='compounded',
desc="Return the compound percentage of the values for "
"the requested axis", name1=name, name2=name2,
axis_descr=axis_descr,
min_count='', examples='')
axis_descr=axis_descr, min_count='', see_also='',
examples='')
@Appender(_num_doc)
def compound(self, axis=None, skipna=None, level=None):
if skipna is None:
Expand Down Expand Up @@ -9687,16 +9687,16 @@ def compound(self, axis=None, skipna=None, level=None):
nanops.nanmedian)
cls.max = _make_stat_function(
cls, 'max', name, name2, axis_descr,
"""This method returns the maximum of the values in the object.
If you want the *index* of the maximum, use ``idxmax``. This is
the equivalent of the ``numpy.ndarray`` method ``argmax``.""",
nanops.nanmax, _max_examples)
"Return the maximum of the values in the object."
"\n\nIf you want the *index* of the maximum, use ``idxmax``. This "
"is the equivalent of the ``numpy.ndarray`` method ``argmax``.",
nanops.nanmax, _min_max_see_also, _max_examples)
cls.min = _make_stat_function(
cls, 'min', name, name2, axis_descr,
"""This method returns the minimum of the values in the object.
If you want the *index* of the minimum, use ``idxmin``. This is
the equivalent of the ``numpy.ndarray`` method ``argmin``.""",
nanops.nanmin)
"Return the minimum of the values in the object."
"\n\nIf you want the *index* of the minimum, use ``idxmin``. This "
"is the equivalent of the ``numpy.ndarray`` method ``argmin``.",
nanops.nanmin, _min_max_see_also, _max_examples)

@classmethod
def _add_series_only_operations(cls):
Expand Down Expand Up @@ -10008,21 +10008,32 @@ def _doc_parms(cls):

Parameters
----------
axis : %(axis_descr)s
skipna : boolean, default True
axis : %(axis_descr)s, default 0
Indicate which axis should be reduced. Not implemented for Series.

* 0 / ‘index’ : reduce the index, return a Series whose index is the
original column labels.
* 1 / ‘columns’ : reduce the columns, return a Series whose index is the
original index.
For a DataFrame the value 0 applies %(outname)s on each column, and 1
applies it on each row.
skipna : bool, default True
Exclude NA/null values when computing the result.
level : int or level name, default None
If the axis is a MultiIndex (hierarchical), count along a
particular level, collapsing into a %(name1)s
numeric_only : boolean, default None
Include only float, int, boolean columns. If None, will attempt to use
particular level, collapsing into a %(name1)s.
numeric_only : bool, default None
Include only float, int, bool columns. If None, will attempt to use
everything, then use only numeric data. Not implemented for Series.
%(min_count)s\
**kwargs : any, default None
Additional keyword arguments.

Returns
-------
%(outname)s : %(name1)s or %(name2)s (if level specified)\
%(outname)s : %(name1)s or %(name2)s (if level specified)

%(see_also)s
%(examples)s"""

_num_ddof_doc = """
Expand Down Expand Up @@ -10506,6 +10517,19 @@ def _doc_parms(cls):
Series([], dtype: bool)
"""

_min_max_see_also = """\
See Also
--------
Series.min : Return the minimum.
Series.max : Return the maximum.
Series.idxmin : Return the index of the minimum.
Series.idxmax : Return the index of the maximum.
DataFrame.min : Return the minimum over the requested axis.
DataFrame.max : Return the maximum over the requested axis.
DataFrame.idxmin : Return the index of the minimum over the requested axis.
DataFrame.idxmax : Return the index of the maximum over the requested axis.
"""

_sum_examples = """\
Examples
--------
Expand Down Expand Up @@ -10625,7 +10649,6 @@ def _doc_parms(cls):
dtype: int64
"""


_min_count_stub = """\
min_count : int, default 0
The required number of valid values to perform the operation. If fewer than
Expand All @@ -10643,7 +10666,7 @@ def _make_min_count_stat_function(cls, name, name1, name2, axis_descr, desc,
f, examples):
@Substitution(outname=name, desc=desc, name1=name1, name2=name2,
axis_descr=axis_descr, min_count=_min_count_stub,
examples=examples)
see_also='', examples=examples)
@Appender(_num_doc)
def stat_func(self, axis=None, skipna=None, level=None, numeric_only=None,
min_count=0,
Expand All @@ -10663,9 +10686,10 @@ def stat_func(self, axis=None, skipna=None, level=None, numeric_only=None,


def _make_stat_function(cls, name, name1, name2, axis_descr, desc, f,
examples=''):
see_also='', examples=''):
@Substitution(outname=name, desc=desc, name1=name1, name2=name2,
axis_descr=axis_descr, min_count='', examples=examples)
axis_descr=axis_descr, min_count='', see_also=see_also,
examples=examples)
@Appender(_num_doc)
def stat_func(self, axis=None, skipna=None, level=None, numeric_only=None,
**kwargs):
Expand Down