Skip to content
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

Merged
merged 3 commits into from
Aug 31, 2021

Conversation

debnathshoham
Copy link
Member

@jreback jreback added Categorical Categorical Data Type Groupby Testing pandas testing functions or related to the test suite labels Aug 21, 2021
@jreback jreback added this to the 1.4 milestone Aug 21, 2021
pandas/tests/groupby/test_categorical.py Outdated Show resolved Hide resolved
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])
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

amended

Copy link
Member

@phofl phofl left a comment

Choose a reason for hiding this comment

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

Lgtm

@jreback jreback merged commit a6943ae into pandas-dev:master Aug 31, 2021
@jreback
Copy link
Contributor

jreback commented Aug 31, 2021

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)

@debnathshoham debnathshoham deleted the gh33090 branch September 1, 2021 05:45
feefladder pushed a commit to feefladder/pandas that referenced this pull request Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Groupby Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SeriesGroupBy.first / last loses categorical dtype
3 participants