Skip to content

DEPR: make Series.agg aggregate when possible #53325

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 11 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix doc build
  • Loading branch information
topper-123 committed Jun 6, 2023
commit 57b76eb1f08bcae0417b2a72b0cad64f2b891ce6
11 changes: 6 additions & 5 deletions doc/source/whatsnew/v2.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,14 @@ Now user-defined functions in :meth:`Series.agg` will always be passed the whole
*New behavior*:

.. ipython:: python
:okexcept:

ser = pd.Series([1, 2, 3])
ser.agg(lambda x: np.sum(x, where=True)) # fails, as it should
ser.agg(type)
ser.agg(type) == ser.to_frame().agg(type)[0]
ser = pd.Series([1, 2, 3])
ser.agg(lambda x: np.sum(x, where=True)) # fails, as it should
ser.agg(type)
ser.agg(type) == ser.to_frame().agg(type)[0]

More generally, the result from :meth:`Series.agg` will now always be the same as the single-column result from :meth:`DataFrame.agg` (:issue:`53324`).
More generally, the result from :meth:`Series.agg` will now always be the same as the single-column result from :meth:`DataFrame.agg` (:issue:`53325`).


.. _whatsnew_210.notable_bug_fixes.notable_bug_fix2:
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/apply/test_series_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ def test_apply_map_evaluate_lambdas_the_same(string_series, func, by_row):


def test_agg_evaluate_lambdas(string_series):
# GH53325
expected = Series

result = string_series.agg(lambda x: type(x))
Expand Down