Skip to content

[DOC] Fix issues with DataFrame.aggregate page #24948

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
13 changes: 2 additions & 11 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -6224,16 +6224,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.
Expand Down Expand Up @@ -6280,7 +6271,7 @@ def _gotitem(self,
dtype: float64
""")

@Substitution(see_also=_agg_summary_and_see_also_doc,
@Substitution(see_also=_agg_see_also_doc,
examples=_agg_examples_doc,
versionadded='.. versionadded:: 0.20.0',
**_shared_doc_kwargs)
Expand Down
15 changes: 11 additions & 4 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4913,6 +4913,13 @@ def pipe(self, func, *args, **kwargs):
_shared_docs['aggregate'] = dedent("""
Aggregate using one or more operations over the specified axis.

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)``.

%(versionadded)s

Parameters
Expand All @@ -4936,10 +4943,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

Expand Down