-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: lambda
with positional references in apply
after groupby
on empty dataframe errors
#46496
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
Comments
Thanks for the report! |
returns empty series with object dtype in pandas-1.3.5 first bad commit: [884d00f] TST: fix groupby-empty xfails (#44092) #44092 has a code change despite the PR title and no release note about the change in behavior. NOTE: both |
will perhaps revert #44092 later today to get this fixed for released pandas. |
moving to 1.4.4 to allow time to investigate alternatives properly. |
This is an instance of a common issue with apply/agg/transform with a UDF on an empty frame/series. If we don't ever call the function, we can't infer the shape of the output. If we do call the function, it can fail as it does here. As a band-aid, I'm thinking we should wrap the However, I think we should align on a solution to how empty objects are handled across the apply/agg/transform implementations and document it for users. I plan to put up a tracking issue on this. |
removing from 1.4.x milestone. |
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
apply on empty series after groupby attempts to evaluate and errors
Expected Behavior
returns empty series
Installed Versions
{
"date": "2022-02-12T09:04:11+0000",
"dirty": false,
"error": null,
"full-revisionid": "06d230151e6f18fdb8139d09abf539867a8cd481",
"version": "1.4.1"
}
The text was updated successfully, but these errors were encountered: