Home > Software design >  Compare two pandas series and remove duplicate
Compare two pandas series and remove duplicate

Time:09-29

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:

>>> 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

CodePudding user response:

(set(ser1).difference(ser2))
{1, 2, 3}
  • Related