Skip to content
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

DOC: Added Examples for Series max #23298

Merged
merged 7 commits into from
Oct 25, 2018
Merged
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
45 changes: 42 additions & 3 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9362,7 +9362,7 @@ def compound(self, axis=None, skipna=None, level=None):
"""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)
nanops.nanmax, _max_examples)
cls.min = _make_stat_function(
cls, 'min', name, name2, axis_descr,
"""This method returns the minimum of the values in the object.
Expand Down Expand Up @@ -10210,6 +10210,44 @@ def _doc_parms(cls):
nan
"""

_max_examples = """\
Examples
--------
``MultiIndex`` series example of monthly rainfall

>>> index = pd.MultiIndex.from_product(
... [['London', 'New York'], ['Jun', 'Jul', 'Aug']],
... names=['city', 'month'])
>>> s = pd.Series([47, 35, 54, 112, 117, 113], index=index)
>>> s
city month
London Jun 47
Jul 35
Aug 54
New York Jun 112
Jul 117
Aug 113
dtype: int64

>>> s.max()
117

Max using level names, as well as indices

>>> s.max(level='city')
city
London 54
New York 117
dtype: int64

>>> s.max(level=1)
month
Jun 112
Jul 117
Aug 113
dtype: int64
"""


_min_count_stub = """\
min_count : int, default 0
Expand Down Expand Up @@ -10247,9 +10285,10 @@ def stat_func(self, axis=None, skipna=None, level=None, numeric_only=None,
return set_function_name(stat_func, name, cls)


def _make_stat_function(cls, name, name1, name2, axis_descr, desc, f):
def _make_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='', examples='')
axis_descr=axis_descr, min_count='', examples=examples)
@Appender(_num_doc)
def stat_func(self, axis=None, skipna=None, level=None, numeric_only=None,
**kwargs):
Expand Down