Skip to content

DOC: Added MultiIndex Example for Series Min #23338

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

Merged
merged 32 commits into from
Dec 25, 2018
Merged
Changes from 25 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1a7247a
DOC: Added multi-indexed example for series.max
Oct 23, 2018
29f7887
DOC: truncated line for PEP compliance
Oct 23, 2018
3a13f43
Merge branch 'master' of github.com:pandas-dev/pandas into series-max
Oct 23, 2018
ae6aadf
DOC: Added Examples for Series Min
Oct 24, 2018
c16f48b
DOC: Typo corrected.
Oct 25, 2018
260790d
DOC: Restructured indexing as requested.
Oct 25, 2018
ad97502
DOC: Switched from MultiIndex.from_arrays to MultiIndex.from_product
Oct 25, 2018
469b764
Merge branch 'master' into series-min
Oct 25, 2018
5084c31
Merge branch 'master' of github.com:pandas-dev/pandas into series-min
Oct 25, 2018
6ac044d
Formatting Indentation for PEP compliance
Oct 25, 2018
3baa4d2
Merge branch 'master' of github.com:pandas-dev/pandas into series-min
Oct 26, 2018
8b4fd1d
DOC: Initial templating of stat_func multiIndex examples
Oct 28, 2018
0a961a4
DOC: Refactored templating of stat_func multiIndex examples for Pytho…
Nov 4, 2018
bea2ecd
DOC: Removed spurious f
Nov 4, 2018
be103f6
Merge branch 'master' of github.com:pandas-dev/pandas into series-min
Nov 4, 2018
be4bf1b
Merge branch 'master' of github.com:pandas-dev/pandas into series-min
Nov 5, 2018
af16a3b
DOC: Refactoring for simplicity
Nov 5, 2018
23ed6b8
DOC: Corrected None to empty string
Nov 5, 2018
efc8c50
Merge branch 'master' of github.com:pandas-dev/pandas into series-min
Nov 5, 2018
12f3d9d
DOC: Formatting
Nov 5, 2018
4a4632f
Merge branch 'master' of github.com:pandas-dev/pandas into series-min
Nov 6, 2018
2424521
DOC: Corrected example output
Nov 6, 2018
77c866e
DOC: Updated stat func base example
Dec 1, 2018
aa2d228
DOC: Updated stat func sum, min and max examples for clarity.
Dec 1, 2018
48e7dfc
DOC: Updated string variables from old format -> new.
Dec 1, 2018
aeba748
DOC: Formatting update.
Dec 2, 2018
c230c3b
DOC: Updated sum, min & max for complete doc string compliance.
Dec 2, 2018
b7f3dcf
Merge branch 'master' of github.com:pandas-dev/pandas into series-min
Dec 3, 2018
d612e7c
Merge branch 'master' of github.com:pandas-dev/pandas into series-min
Dec 3, 2018
9270def
Merge branch 'master' of github.com:pandas-dev/pandas into series-min
Dec 3, 2018
a4c0e9c
Merge branch 'master' into series-min
Dec 22, 2018
8ec816a
Merge branch 'master' of github.com:pandas-dev/pandas into series-min
Dec 22, 2018
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
126 changes: 54 additions & 72 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9602,7 +9602,7 @@ def compound(self, axis=None, skipna=None, level=None):
"""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)
nanops.nanmin, _min_examples)

@classmethod
def _add_series_only_operations(cls):
Expand Down Expand Up @@ -10397,43 +10397,50 @@ def _doc_parms(cls):
Series([], dtype: bool)
"""

_sum_examples = """\
_shared_docs['stat_func_example'] = """\
Examples
--------
``MultiIndex`` series example of monthly rainfall
``MultiIndex`` series example.

>>> 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)
>>> index = pd.MultiIndex.from_arrays([
... ['Warm', 'Warm', 'Cold', 'Cold'],
... ['Dog', 'Falcon', 'Fish', 'Spider']],
... names=['Blooded', 'Animal'])
>>> s = pd.Series([4, 2, 0, 8], name='Legs', index=index)
>>> s
city month
London Jun 47
Jul 35
Aug 54
New York Jun 112
Jul 117
Aug 113
dtype: int64

>>> s.sum()
478

Sum using level names, as well as indices

>>> s.sum(level='city')
city
London 136
New York 342
dtype: int64

>>> s.sum(level=1)
month
Jun 159
Jul 152
Aug 167
dtype: int64
Blooded Animal
Warm Dog 4
Falcon 2
Cold Fish 0
Spider 8
Name: Legs, dtype: int64

>>> s.{stat_func}()
{default_output}

{verb} using level names, as well as indices.

>>> s.{stat_func}(level='Blooded')
Blooded
Warm {level_output_0}
Cold {level_output_1}
Name: Legs, dtype: int64

>>> s.{stat_func}(level=0)
Blooded
Warm {level_output_0}
Cold {level_output_1}
Name: Legs, dtype: int64
"""

_sum_examples = _shared_docs['stat_func_example'].format(
stat_func='sum',
verb='Sum',
default_output=14,
level_output_0=6,
level_output_1=8)

_sum_examples += """
By default, the sum of an empty or all-NA Series is ``0``.

>>> pd.Series([]).sum() # min_count=0 is the default
Expand All @@ -10455,6 +10462,20 @@ def _doc_parms(cls):
nan
"""

_max_examples = _shared_docs['stat_func_example'].format(
stat_func='max',
verb='Max',
default_output=8,
level_output_0=4,
level_output_1=8)

_min_examples = _shared_docs['stat_func_example'].format(
stat_func='min',
verb='Min',
default_output=0,
level_output_0=2,
level_output_1=0)

_prod_examples = """\
Examples
--------
Expand All @@ -10478,45 +10499,6 @@ 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
The required number of valid values to perform the operation. If fewer than
Expand Down