Get column values not exist in another column pandas

I have two dataframe df1 and df2, df1 & df2 have column "A". I want output df3 has column "A" which has values of df1 not exist on df2.

df1                 
A
I-13856942
I-13856914
I-13861633
I-13875002
I-13875673

df2

A
I-13856942
I-13856914
I-13861633

output
df3

A
I-13875002
I-13875673

>Solution :

A possible solution:

df1.loc[df1.merge(df2, how='left', indicator=True)['_merge'].eq('left_only'),:]

Output:

            A
3  I-13875002
4  I-13875673

Leave a Reply