Skip to content

BUG: GroupBy.agg allows non-aggregating built-in functions #58284

Closed
@WillAyd

Description

@WillAyd

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

In [38]: df = pd.DataFrame({"group": list("aab"), "val1": range(3)})

In [39]: df.groupby("group").agg("cumsum")
Out[39]: 
   val1
0     0
1     1
2     2

In [40]: df.groupby("group").agg(lambda x: x.cumsum())
ValueError: Must produce aggregated value

Issue Description

The built-in transformation functions are allowed as arguments to .agg. Haven't checked yet that this is solved by @rhshadrach work in #57706

Expected Behavior

Error for built-in functions

Installed Versions

'3.0.0.dev0+681.g434fda08cf'

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions