Search code examples
pandascomparedistinct-values

Show values that doesn't matching between two columns oof 2 data frames in pandas


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!

Solution

  • He needs what is not in df2

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