Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading