Is it possible to do a right join where key is null in python pandas. That is, can I join DateFrames to produce only values from the right that do not match the left?
I think this is best expressed as an index selection operation. To find all indices in one frame and not in another, try using the -
operator on the two Dataframe index
objects, as if the index objects were built-in python set objects. for example:
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[set(dfb.index) - set(dfa.index)]
Out[5]:
A
5 12
6 13
7 14
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With