Home > Net >  Create a set from two datasets with only values from df1 that isnt in df2
Create a set from two datasets with only values from df1 that isnt in df2

Time:11-19

I have 2 dataframes.

I want to create a series with locations from df1 that arent duplicated in df2.

i am confused how to do this, any answers appreciated

CodePudding user response:

From df_1 :

>>> df_1
    values
0   a
1   b
2   c
3   d
4   e

And df_2 :

>>> df_2
    values
0   b
1   e
2   f
3   g

We can get the values from df_1 non duplicated in df_2 using the method isin like so :

>>> df_1[~df_1['values'].isin(df_2['values'])]
    values
0   a
2   c
3   d
  • Related