1
d1 = df1.filter(items=['col_a']) # len(d1) = 900
d2 = df.filter(items=['col_a']) # len(d2) = 920

d1 ---------->
    col_a
0   802584
1   408852
2   408311
3   409633
4   801848
5   123123
6   232333

d2 ---------->
    col_a
0   802584
1   408852
2   408311
3   409633
4   801848

col_a is integer value and I want to compare between d1 and d2 to extract differences.

How can I get a new dataframe that includes only 20 values for col_a?

In this situation, I want to get

new_df ----->
     col_a
0    123123
1    232333

Daniel Lee
  • 27
  • 6

1 Answers1

2

You can do this using df.isin and negation (~):

In [1278]: d1[~d1.col_a.isin(d2.col_a)]
Out[1278]: 
    col_a
5  123123
6  232333
halfer
  • 19,824
  • 17
  • 99
  • 186
Mayank Porwal
  • 33,470
  • 8
  • 37
  • 58