-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Keep categorical name in groupby #28798
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
Conversation
lgtm. over to @topper-123 |
@topper-123 Not sure if it was related to using the fixture, but was getting some test failures due to column order after the update, so added a |
def test_groupby_cat_preserves_structure(observed): | ||
# GH 28787 | ||
df = DataFrame({"Name": Categorical(["Bob", "Greg"]), "Item": [1, 2]}) | ||
expected = df.copy() |
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.
specify columns= here to fix the ordering rather using check_like
Thanks, @dsaxton! |
* BUG: Keep categorical name in groupby
* BUG: Keep categorical name in groupby
* BUG: Keep categorical name in groupby
black pandas
Fixes an issue where column name information was getting dropped when grouping by a categorical column. I had to change a couple existing tests which I think were incorrect since they were implicitly assuming this behavior was expected. Also confirmed that this fixes the problem from #28787: