Skip to content

ENH: Enable DataFrame.groupby(...).transform('size') #45704

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
rhshadrach opened this issue Jan 29, 2022 · 1 comment
Closed

ENH: Enable DataFrame.groupby(...).transform('size') #45704

rhshadrach opened this issue Jan 29, 2022 · 1 comment
Labels
Duplicate Report Duplicate issue or pull request Enhancement Groupby

Comments

@rhshadrach
Copy link
Member

df = pd.DataFrame({'a': [1, 1, 2, 2, 2], 'b': [3, 4, 5, 6, 7]})
gb = df.groupby(df["a"])
print(gb.transform('size'))

raises TypeError: Transform function invalid for data types, but I think a reasonable expectation is to have the result of gb.size() broadcasted:

0    2
1    2
2    3
3    3
4    3
dtype: int64

where gb.size() produces

a
1    2
2    3
dtype: int64
@rhshadrach rhshadrach added Enhancement Groupby Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 29, 2022
@rhshadrach rhshadrach assigned rhshadrach and unassigned rhshadrach Jan 29, 2022
@rhshadrach
Copy link
Member Author

Closing as duplicate of #27469

@rhshadrach rhshadrach added Duplicate Report Duplicate issue or pull request and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request Enhancement Groupby
Projects
None yet
Development

No branches or pull requests

1 participant