-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
TST: groupby.first/last retains categorical dtype #43153
Conversation
debnathshoham
commented
Aug 21, 2021
- closes SeriesGroupBy.first / last loses categorical dtype #33090
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
df = DataFrame({"a": [1, 2, 3]}) | ||
df["b"] = df["a"].astype("category") | ||
result = getattr(df.groupby("a")["b"], func)() | ||
expected = Series(Categorical([1, 2, 3]), name="b", index=[1, 2, 3]) |
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.
You can do index=Index([1, 2, 3], name="a")
otherwise lgtm
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.
amended
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.
Lgtm
thanks @debnathshoham since we get a lot of PRs, periodically rebasing yours is a good idea as it moves them to the front of the queue (assuming they are ready to go) |