I have two dataframes with MultiIndexes, and I need to right join them and then get the items on the right side which didn't have a key match.
The preferred answer for how to do right join where key is null in python pandas suggests to do something like this:
In [1]: dfa = pd.DataFrame({'A': range(5)}, index=range(5))
In [2]: dfb = pd.DataFrame({'A': range(10, 15)}, index=range(3,8))
In [3]: dfa
Out[3]:
A
0 0
1 1
2 2
3 3
4 4
In [4]: dfb
Out[4]:
A
3 10
4 11
5 12
6 13
7 14
In [5]: dfb.loc[dfb.index - dfa.index]
Out[5]:
A
5 12
6 13
7 14
but when I try that with my code, I get an error:
TypeError: cannot perform __sub__ with this index type: <class 'pandas.core.indexes.multi.MultiIndex'>
What options do I have given that MultiIndexes can't be subtracted from one another?