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

Compare two pandas series and remove duplicate

I am new here and i just start programming in python.

I have two series:

ser1 = pd.Series([1,2,3,4,5])
ser2 = pd.Series([4,5,6,7,8])

And i want to compare ser1 and ser2 and then remove the duplicate one to ser1 to have something like this:

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

>>> ser1
    out = 1 2 3

i tried pd.concat but This gave me the combine of the two series wihtout the duplicate

thanks in advance

>Solution :

(set(ser1).difference(ser2))
{1, 2, 3}
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