Reindexing doesn't work as expected for MultiIndexs #12181
Labels
Duplicate Report
Duplicate issue or pull request
Enhancement
MultiIndex
Reshaping
Concat, Merge/Join, Stack/Unstack, Explode
Using
Series.reindex()
does not work when the Series uses a MultiIndex and the desired re-index also uses a MultiIndex. An error message reports that the join is ambiguous, even when it is not.In the following example, I'm setting up some schedule data for individuals who belong to households. Three tables will be created:
households
,persons
, andactivities
. There is an implicit hierarchy: activities belong to persons which belong to households. Their indexes reflect this relationship.Going from a regular Index to a MultiIndex works as expected. In this case, I'm trying to join
dwelling_type
data from the households table to the persons table:But when I try to do a similar operation, joining
age
from persons to activities, I get an error:This seems to be a completely unintuitive result, given that the relationship is unambiguously one-to-many, even though MultiIndex's are used.
I'm able to work around this by dropping levels and replacing Indexs, but to me it seems that this should just be an easy thing to accomplish.
The text was updated successfully, but these errors were encountered: