-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
CategoricalIndex reidex duplicates values #21809
Comments
Seems to be an issue with the DataFrame constructor. In [11]: idx = pd.CategoricalIndex(['low', 'low', 'hi', 'hi'])
In [12]: pd.DataFrame(pd.DataFrame({"A": [1, 2, 3, 4]}, index=idx), index=idx)
Out[12]:
A
low 1
low 2
low 1
low 2
hi 3
hi 4
hi 3
hi 4 Would welcome further investigate from others! |
The problem seems to be with the >>> idx = pd.CategoricalIndex(['low', 'low', 'hi', 'hi'])
>>> idx.reindex(idx)[0].values
[low, low, low, low, hi, hi, hi, hi]
Categories (2, object): [hi, low] Update: pandas/pandas/core/indexes/category.py Lines 589 to 602 in bdb6168
changing line 601 to: indexer, missing = self._engine.get_indexer_non_unique(np.unique(codes)) helps and doesn't break tests, but I'm not sure that it's correct |
Thanks for investigating further. We probably don't want to |
Hmm, |
From SO question:
Sample:
Round incorrectly explode rows:
Expected output:
The text was updated successfully, but these errors were encountered: