Skip to content

Commit b6db80a

Browse files
vadakattuPingviinituutti
authored andcommitted
DOC: Added Examples for Series max (pandas-dev#23298)
1 parent f46b9fe commit b6db80a

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

pandas/core/generic.py

+42-3
Original file line numberDiff line numberDiff line change
@@ -9381,7 +9381,7 @@ def compound(self, axis=None, skipna=None, level=None):
93819381
"""This method returns the maximum of the values in the object.
93829382
If you want the *index* of the maximum, use ``idxmax``. This is
93839383
the equivalent of the ``numpy.ndarray`` method ``argmax``.""",
9384-
nanops.nanmax)
9384+
nanops.nanmax, _max_examples)
93859385
cls.min = _make_stat_function(
93869386
cls, 'min', name, name2, axis_descr,
93879387
"""This method returns the minimum of the values in the object.
@@ -10229,6 +10229,44 @@ def _doc_parms(cls):
1022910229
nan
1023010230
"""
1023110231

10232+
_max_examples = """\
10233+
Examples
10234+
--------
10235+
``MultiIndex`` series example of monthly rainfall
10236+
10237+
>>> index = pd.MultiIndex.from_product(
10238+
... [['London', 'New York'], ['Jun', 'Jul', 'Aug']],
10239+
... names=['city', 'month'])
10240+
>>> s = pd.Series([47, 35, 54, 112, 117, 113], index=index)
10241+
>>> s
10242+
city month
10243+
London Jun 47
10244+
Jul 35
10245+
Aug 54
10246+
New York Jun 112
10247+
Jul 117
10248+
Aug 113
10249+
dtype: int64
10250+
10251+
>>> s.max()
10252+
117
10253+
10254+
Max using level names, as well as indices
10255+
10256+
>>> s.max(level='city')
10257+
city
10258+
London 54
10259+
New York 117
10260+
dtype: int64
10261+
10262+
>>> s.max(level=1)
10263+
month
10264+
Jun 112
10265+
Jul 117
10266+
Aug 113
10267+
dtype: int64
10268+
"""
10269+
1023210270

1023310271
_min_count_stub = """\
1023410272
min_count : int, default 0
@@ -10266,9 +10304,10 @@ def stat_func(self, axis=None, skipna=None, level=None, numeric_only=None,
1026610304
return set_function_name(stat_func, name, cls)
1026710305

1026810306

10269-
def _make_stat_function(cls, name, name1, name2, axis_descr, desc, f):
10307+
def _make_stat_function(cls, name, name1, name2, axis_descr, desc, f,
10308+
examples=''):
1027010309
@Substitution(outname=name, desc=desc, name1=name1, name2=name2,
10271-
axis_descr=axis_descr, min_count='', examples='')
10310+
axis_descr=axis_descr, min_count='', examples=examples)
1027210311
@Appender(_num_doc)
1027310312
def stat_func(self, axis=None, skipna=None, level=None, numeric_only=None,
1027410313
**kwargs):

0 commit comments

Comments
 (0)