Home > Back-end >  Show values that doesn't matching between two columns oof 2 data frames in pandas
Show values that doesn't matching between two columns oof 2 data frames in pandas

Time:03-21

I would like to see the non-matching values of two columns of 2 data frames, and also if possible doing like a distinct count of those values that way won't show them repeated

I got these colums from 2 data frames:

df1:

ID

M1
M1
M2
M2
M3
M4
M5
M5
M6
M6

df2:

ID

M1
M1
M2
M2
M3
M3

expected result:

Output:
M4
M5
M6


Thanks!

CodePudding user response:

He needs what is not in df2

out = df1.loc[~df1.ID.isin(df2.ID)].unique()

CodePudding user response:

You can check with isin with unique

out = df1.loc[~df1.ID.isin(df2.ID)].unique()
  • Related