You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
While building a custom aggregation function to use with pandas.core.groupby.DataFrameGroupBy.aggregate, I noticed a really weird behaviour: the .aggregate() function provides an *arg parameter to provide args to the grouping function, but this, which shouldn't really change what's passed to the function, actually does: when the function has no arguments, it receives a pd.Series (which is unexpected, as according to the docs, if a function, must either work when passed a DataFrame or when passed to DataFrame.apply.), while if you add an argument it behaves as expected and gets a DataFrame.
Expected Behavior
The aggregating function gets a pd.DataFrame regardless of having passed args or not.
mroeschke
changed the title
BUG: Adding a random argument to DataFrameGroupBy.aggregate changes the grouping.
BUG: Adding a random function argument to DataFrameGroupBy.aggregate changes the grouping object from Series to DataFrame.
Aug 11, 2022
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
Issue Description
Hi!
While building a custom aggregation function to use with
pandas.core.groupby.DataFrameGroupBy.aggregate
, I noticed a really weird behaviour: the.aggregate()
function provides an*arg
parameter to provide args to the grouping function, but this, which shouldn't really change what's passed to the function, actually does: when the function has no arguments, it receives a pd.Series (which is unexpected, as according to the docs, if a function, must either work when passed a DataFrame or when passed to DataFrame.apply.), while if you add an argument it behaves as expected and gets a DataFrame.Expected Behavior
The aggregating function gets a
pd.DataFrame
regardless of having passed args or not.Installed Versions
The text was updated successfully, but these errors were encountered: