findout not common values between two data frames 1

findout not common values between two data frames

df = df1.merge(df2, how = 'outer' ,indicator=True).loc[lambda x : x['_merge']=='left_only']
 
df

Here is what the above code is Doing:
1. We are merging the two dataframes on the column ‘Name’
2. We are using the ‘outer’ method, which means that we want to keep all the rows from both dataframes
3. We are using the ‘indicator’ parameter, which adds a column to the dataframe called ‘_merge’
4. We are using the ‘loc’ method to filter the dataframe to only keep the rows where the ‘_merge’ column is equal to ‘left_only’

Similar Posts