We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
In [1]: import pandas as pd In [2]: a = pd.Series(['a', 'b', 'c']) In [3]: dtype = pd.api.types.CategoricalDtype(['x', 'y', 'z']) In [4]: b = a.astype('category') In [5]: b Out[5]: 0 a 1 b 2 c dtype: category Categories (3, object): [a, b, c] In [6]: b.astype(dtype) Out[6]: 0 a 1 b 2 c dtype: category Categories (3, object): [a, b, c] In [7]: pd.__version__ Out[7]: '0.21.0'
I'd expect b.astype(dtype) to re-categorize b with the new categories from the categorical dtype. Instead, it seems this operation is ignored.
b.astype(dtype)
b
The text was updated successfully, but these errors were encountered:
yeah this ignore it if its already categorical, agree should check if the cat is different and reconstruct a new one.
happy to take a PR
Sorry, something went wrong.
cc @chris-b1
See also #10696
Successfully merging a pull request may close this issue.
I'd expect
b.astype(dtype)
to re-categorizeb
with the new categories from the categorical dtype. Instead, it seems this operation is ignored.The text was updated successfully, but these errors were encountered: