1

Assume I have two datatables, identical shape, say N rows and 2 columns. They have same columns names "One", "Two"

Call first table "left", then call second table "right".

How can I return a new datatable FROM table "Left", when value from two tables in column "One" are not equal?

EX:

Table "Left"
One    Two
1       2
1       2
2       3
2       5
3       6


Table "Right"
One    Two
1       2
2       2
2       3
5       5
3       8


Output Table 
One    Two
1       2
2       5

Thank you!

Cœur
  • 37,241
  • 25
  • 195
  • 267
Windtalker
  • 776
  • 4
  • 13
  • 23
  • @Psidom When column "One" is not equal, return all values ONLY from left – Windtalker Mar 23 '17 at 03:29
  • Just figured out your logic. You can check the answer. Basically construct the boolean series with the condition and subset the left data frame. – Psidom Mar 23 '17 at 03:31

1 Answers1

2

Think you need this:

left[left.One.values != right.One.values]

# One   Two
#1  1     2
#3  2     5
Psidom
  • 209,562
  • 33
  • 339
  • 356
  • Had tried this, raised error "ValueError: Can only compare identically-labeled Series objects" – Windtalker Mar 23 '17 at 03:32
  • You might have different index from `left` and `right`, if you don't care about the index, you can compare the numpy array of Column *one* with *values*. – Psidom Mar 23 '17 at 03:35
  • I see. Index might be the issue. But with values at least I got an output, just need to verify if it is what I want. Thank you so much! – Windtalker Mar 23 '17 at 03:38