Home > OS >  Pandas - Find unique values in the same column across multiple data frames
Pandas - Find unique values in the same column across multiple data frames

Time:09-30

I have two Dataframe with the same structure. I would like to find the unique values in the same column across these two Dataframe.

df1 structure:

emp_id, salary
101, 100
102, 102

df2 structure:

emp_id, salary
101, 100
201, 105

Expected output:

 emp_id
 101
 102
 201

CodePudding user response:

Try with append and drop_duplicates:

>>> df1.append(df2).drop_duplicates("emp_id")["emp_id"]
0    101
1    102
1    201
Name: emp_id, dtype: int64
  • Related