Skip to content

BUG/TST Added support for empty dictionary when passed to agg for gro… #50192

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

Closed
wants to merge 2 commits into from

Conversation

eshanja1n
Copy link

…upby

This adds consistency across empty containers when passed to agg for groupby. Also added new test to check new functionality works as expected.

…upby

This adds consistency across empty containers when passed to agg for groupby. Also added new test to check new functionality works as expected.
# empty list and tuple
from pandas import DataFrame

result = DataFrame()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does type(selected_object)() work here?

@mroeschke mroeschke added Groupby Apply Apply, Aggregate, Transform, Map labels Dec 13, 2022


def test_empty_container_consistency():
df = DataFrame(data={"a": [1, 2], "b": [3, 4], "c": [5, 6]})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the GitHub Issue number as a comment in the first line

Comment on lines +417 to +420
# GH 48581 - Adding consistency to empty agg types
if not results:
# return empty DataFrame if results is empty, following pattern
# empty list and tuple
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the comments here can be removed; I think it's clear that the else code path will fail in this case and why we're returning an empty frame.

@rhshadrach rhshadrach added the Bug label Dec 13, 2022
@github-actions
Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Jan 13, 2023
@mroeschke
Copy link
Member

Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen.

@mroeschke mroeschke closed this Jan 18, 2023
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 Groupby Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Inconsistency when empty inputs are passed to agg for groupby
4 participants