How can I do a left outer join, excluding the intersection, in Pandas?
I have 2 pandas dataframes
df1 = pd.DataFrame(data = {'col1' : ['finance', 'finance', 'finance', 'accounting', 'IT'], 'col2' : ['az', 'bh', '', '', '']})
df2 = pd.DataFrame(data = {'col1' : ['finance', 'finance', 'finance', 'finance', 'finance'], 'col2' : ['', 'az', '', '', '']})
df1
col1 col2
0 finance az
1 finance bh
2 finance
3 accounting
4 IT
df2
col1 col2
0 finance
1 finance az
2 finance
3 finance
4 finance
As you can see the dataframe has blank values as well. I tried using the example and its not giving me the result I want.
common = df1.merge(df2,on=['col1','col2'])
df3=df1[(~df1.col1.isin(common.col1))&(~df1.col2.isin(common.col2))]
I want the output to look something like
col1 col2
3 accounting
4 IT