-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
QST: Is it intended that empty dictionary aggregation raises exception since 1.2.0? #39609
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
Open
1 of 2 tasks
Labels
Apply
Apply, Aggregate, Transform, Map
Bug
Needs Discussion
Requires discussion from core team before further action
Comments
6 tasks
If we follow semantic versioning strictly, then this is a regression. A minor version increase should not break any existing API-contract. Example code:import pandas as pd
if __name__ == '__main__':
pd.show_versions()
print()
df = pd.DataFrame(data=[{'a': 1}])
g = df.groupby(by='a')
a = g.aggregate({})
print(a) Output in version
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Apply
Apply, Aggregate, Transform, Map
Bug
Needs Discussion
Requires discussion from core team before further action
I have searched the [pandas] tag on StackOverflow for similar questions.
I have asked my usage related question on StackOverflow.
Question about pandas
Traceback
Since #37227, aggregation with empty dictionary started to raise
ValueError
(previously it return an empty frame) which comes from.concat
when trying to concat results:pandas/pandas/core/apply.py
Line 374 in cb1486c
Since
results
are empty, it's logical that it raise exception. But the logic that was touched by #37277 doesn't touch that.concat
part, so the behavior should stay the same - return an empty frame.Previously it goes to the
concat
branch ifany(cond1(x) for x in agg_dict)
and now it'sall(cond2(x) for x in agg_dict)
.cond1
andcond2
was written in that way so the condition withany
andall
are technically the same. But the difference betweenany
andall
is that they give the different results on an empty sequences:So after
any
was changed toall
it gets to theconcat
branch even ifresults
are empty and gets an error on.concat
.So the question is, is it desired behavior that now aggregation raises exception on empty dict? And if it is, should it catch these cases in
agg_dict_line
and give a nicer error?The text was updated successfully, but these errors were encountered: