diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 31b700abcfdb3..0dcd46fc11475 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -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. @@ -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 @@ -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):