Skip to content

Commit

Permalink
DOC: Added Examples for Series max (#23298)
Browse files Browse the repository at this point in the history
  • Loading branch information
vadakattu authored and WillAyd committed Oct 25, 2018
1 parent 0a2d501 commit c76173b
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9381,7 +9381,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 @@ -10229,6 +10229,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 @@ -10266,9 +10304,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

0 comments on commit c76173b

Please sign in to comment.