diff --git a/pandas/core/frame.py b/pandas/core/frame.py index a239ff4b4d5db..b5bfb74ee24d2 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -6172,16 +6172,7 @@ def _gotitem(self, # TODO: _shallow_copy(subset)? return subset[key] - _agg_summary_and_see_also_doc = dedent(""" - The aggregation operations are always performed over an axis, either the - index (default) or the column axis. This behavior is different from - `numpy` aggregation functions (`mean`, `median`, `prod`, `sum`, `std`, - `var`), where the default is to compute the aggregation of the flattened - array, e.g., ``numpy.mean(arr_2d)`` as opposed to ``numpy.mean(arr_2d, - axis=0)``. - - `agg` is an alias for `aggregate`. Use the alias. - + _agg_see_also_doc = dedent(""" See Also -------- DataFrame.apply : Perform any type of operations. @@ -6226,9 +6217,19 @@ def _gotitem(self, 2 8.0 3 NaN dtype: float64 + """) + _agg_summary = dedent(""" + The aggregation operations are always performed over an axis, either + the index (default) or the column axis. This behavior is different from + `numpy` aggregation functions (`mean`, `median`, `prod`, `sum`, `std`, + `var`), where the default is to compute the aggregation of the + flattened array, e.g., ``numpy.mean(arr_2d)`` as opposed to + ``numpy.mean(arr_2d, axis=0)``. + """) - @Substitution(see_also=_agg_summary_and_see_also_doc, + @Substitution(summary=_agg_summary, + see_also=_agg_see_also_doc, examples=_agg_examples_doc, versionadded='.. versionadded:: 0.20.0', **_shared_doc_kwargs) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 6e79c02d7dbdd..d127ae02219ae 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -4926,6 +4926,8 @@ def pipe(self, func, *args, **kwargs): _shared_docs['aggregate'] = dedent(""" Aggregate using one or more operations over the specified axis. + %(summary)s + %(versionadded)s Parameters @@ -4949,10 +4951,10 @@ def pipe(self, func, *args, **kwargs): Returns ------- DataFrame, Series or scalar - If DataFrame.agg is called with a single function, returns a Series - If DataFrame.agg is called with several functions, returns a DataFrame - If Series.agg is called with single function, returns a scalar - If Series.agg is called with several functions, returns a Series. + - If DataFrame.agg is called with a single function, returns a Series + - If DataFrame.agg is called with several functions, returns a DataFrame + - If Series.agg is called with single function, returns a scalar + - If Series.agg is called with several functions, returns a Series %(see_also)s diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index 52056a6842ed9..317e6f3b39f35 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -747,7 +747,8 @@ def _selection_name(self): def apply(self, func, *args, **kwargs): return super(SeriesGroupBy, self).apply(func, *args, **kwargs) - @Substitution(see_also=_agg_see_also_doc, + @Substitution(summary='', + see_also=_agg_see_also_doc, examples=_agg_examples_doc, versionadded='', klass='Series', @@ -1306,7 +1307,8 @@ class DataFrameGroupBy(NDFrameGroupBy): 2 3 4 0.704907 """) - @Substitution(see_also=_agg_see_also_doc, + @Substitution(summary='', + see_also=_agg_see_also_doc, examples=_agg_examples_doc, versionadded='', klass='DataFrame', diff --git a/pandas/core/resample.py b/pandas/core/resample.py index b3b28d7772713..a206c949d6bf9 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -254,7 +254,8 @@ def pipe(self, func, *args, **kwargs): 2013-01-01 00:00:04 5 NaN """) - @Substitution(see_also=_agg_see_also_doc, + @Substitution(summary='', + see_also=_agg_see_also_doc, examples=_agg_examples_doc, versionadded='', klass='DataFrame', diff --git a/pandas/core/series.py b/pandas/core/series.py index a5dfe8d43c336..2511f3acaac2e 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -3492,7 +3492,8 @@ def _gotitem(self, key, ndim, subset=None): dtype: int64 """) - @Substitution(see_also=_agg_see_also_doc, + @Substitution(summary='', + see_also=_agg_see_also_doc, examples=_agg_examples_doc, versionadded='.. versionadded:: 0.20.0', **_shared_doc_kwargs) diff --git a/pandas/core/window.py b/pandas/core/window.py index 9e29fdb94c1e0..cd266f09532fa 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -733,7 +733,8 @@ def f(arg, *args, **kwargs): 9 0.070889 0.134399 -0.031308 """) - @Substitution(see_also=_agg_see_also_doc, + @Substitution(summary='', + see_also=_agg_see_also_doc, examples=_agg_examples_doc, versionadded='', klass='Series/DataFrame', @@ -1675,7 +1676,8 @@ def _validate_freq(self): 9 0.212668 -1.647453 """) - @Substitution(see_also=_agg_see_also_doc, + @Substitution(summary='', + see_also=_agg_see_also_doc, examples=_agg_examples_doc, versionadded='', klass='Series/Dataframe', @@ -1953,7 +1955,8 @@ def _get_window(self, other=None): 9 -0.286980 0.618493 -0.694496 """) - @Substitution(see_also=_agg_see_also_doc, + @Substitution(summary='', + see_also=_agg_see_also_doc, examples=_agg_examples_doc, versionadded='', klass='Series/Dataframe', @@ -2265,7 +2268,8 @@ def _constructor(self): 9 -0.286980 0.618493 -0.694496 """) - @Substitution(see_also=_agg_see_also_doc, + @Substitution(summary='', + see_also=_agg_see_also_doc, examples=_agg_examples_doc, versionadded='', klass='Series/Dataframe',