You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Interesting. This seems to happen due to the malformed unicode characters, somewhere in the MultIndex calls a search for duplicates (in e.g., ['x-\udce9', 'y-\udce9']) in the index happens via a cython hash map, this duplicate check does not happen for a single level index.
In the end this filters out a false positive duplicate, leading to the ['x-\udce9', 'x-\udce9'] index values in your example.
I don't think changing the hashmap implementation is a good idea, but one could at least throw an exception if the user wants to put malformed unicode into a MultiIndex.
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
When creating a dataframe with an index containing non-ascii chars, pandas is merging different keys into a single key.
returns the same two keys:
Expected behavior:
Note that when using ascii chars, the behavior is correct:
returns two different keys:
Note that the behavior is correct with non-ascii char and using a single column in the index:
returns two different keys:
Issue Description
Creating a multi-index with non-ascii characters will not keep unique indices. Instead, keys are merged.
Expected Behavior
Creating a multi-index with non-ascii characters should keep unique keys.
Installed Versions
The text was updated successfully, but these errors were encountered: