Very unintuitive to join
two dataframes with indexes that overlap partially
#10621
Labels
join
two dataframes with indexes that overlap partially
#10621
I posted a slightly-ranting question about this on StackOverflow.
Basically, I want to use pandas to join two dataframes wherein the index levels of one are a subset of the index levels of the other. For example, the two DFs below have
index.names
of('fruit', 'citrus')
and('citrus',)
respectively:The intuitive approach to joining them fails, because the indexes do not exactly match:
I found a variety of workarounds, none of which I consider very satisfactory. Eventually I found one that doesn't involve giving up on using an index altogether. It involves rebroadcasting the "smaller" index to match the "larger" index:
Is there any reason not to make this behavior automatic?
The text was updated successfully, but these errors were encountered: