-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
BUG: DataFrame.aggregate returns Series for empty DataFrame (#62443) #62444
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
BUG: DataFrame.aggregate returns Series for empty DataFrame (#62443) #62444
Conversation
|
Please run pre-commit locally first and fix any issues there. |
rhshadrach
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, however I'm negative on this approach as it will break certain working cases for users today. I think what is first necessary is a solid proposal of how pandas treats empty objects across the API. This is #47959.
Hmm, I agree. |
Thanks for the feedback! I've now run pre-commit locally and addressed the issues flagged. Let me know if anything else needs adjustment. |
Thanks for the thoughtful review and for pointing me to #47959. I understand the concern about breaking existing behavior, and I agree that a consistent, well-defined approach to handling empty objects across the API is essential before making changes like this. I’ll take a closer look at the ongoing discussion in that issue and see how this case fits into the broader proposal. Happy to revisit this PR once there's more clarity or alignment on the expected behavior. Appreciate your guidance! |
165d80a to
a1c9dad
Compare
|
Thanks for the PR, but going to close pending more discussion in #47959 |
Bug Reference: closes #62443
Bug Description
DataFrame.aggregatehas inconsistent behavior for empty DataFrames:axis='columns') on an empty DataFrame, it raises aValueErrorinstead of returning an empty Series.Fix
Updated
DataFrame.aggregateto handle empty DataFrames consistently.Now, empty DataFrames return an empty Series with the correct index, regardless of axis.
This aligns the behavior with the documented return types:
Test
test_aggregate_empty_dataframe_returns_seriesintest_aggregate.pyto ensure empty DataFrames return an empty Series along both axes (0and'columns').Checklist
test_aggregate_empty_dataframe_returns_seriesdoc/source/whatsnew/v2.3.3.rst(if required)