Get column values not exist in another column pandas

Question:

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
Asked By: asmaa mahmoud

||

Answers:

A possible solution:

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

Output:

            A
3  I-13875002
4  I-13875673
Answered By: PaulS
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.