-
-
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
BUG: unstack doesn't preserve categorical dtype #14018
Comments
Looks to be fixed on master. Could use a test
|
I can take this one? Just need guidance on which test file to edit? First time Git contributor |
Sure @Abhispy007. |
That dtype is the dtype of the resulting Series. Since Series is holding dtype objects, that should be object |
Sorry don't have time for a call. But the output should be as noted in #14018 (comment) |
Came up with this test
Appropriately fails with AssertionError: assert 'object' == 'category'. |
You can use No worries, yes please open a pull request. Discussing the test in a pull request will be a lot easier |
Turns out my test doesn't work... Fails on df[cat].unstack().dtypes as well. |
Code Sample, a copy-pastable example if possible
Categorical dtype is lost:
But it works ok for a Series:
Expected Output
I believe
df.unstack()
should preserve categorical dtypes asdf['cat'].unstack()
does.output of
pd.show_versions()
This is related to #13743 (and PR #13854), though a bit more difficult to fix.
The text was updated successfully, but these errors were encountered: