Say I have two dataframes
df1
df2
that I can join on df1_keys
and df2_keys
.
I would like to do:
(A-B)
(A-B) U (B-A)
with A=df1
and B=df2
.
From what I read on the documentation, the how
argument for pd.merge
supports the following options:
how : {‘left’, ‘right’, ‘outer’, ‘inner’}, default ‘inner’
left: use only keys from left frame (SQL: left outer join)
right: use only keys from right frame (SQL: right outer join)
outer: use union of keys from both frames (SQL: full outer join)
inner: use intersection of keys from both frames (SQL: inner join)
but none of them gives us directly the set operations 1 and 2 above.
For reference, below is the corresponding reference for SQL (from this thread):