0

I want to df1 ∩ df2' in a pandas dataframe

df1 has headers (given below) with 100 rows

  {a , b, c , d,x,y,v }

df2 has headers (given below) with 100 rows

{a, b, e, f,p,o,i}

the output of the join (just using the header names )

{c , d,x,y,v }
Chris D'mello
  • 145
  • 2
  • 9

2 Answers2

2
x1 =set(['a' , 'b', 'c' , 'd','x','y','v'])
x2 = set(['a', 'b', 'e', 'f','p','o','i'])
print(x1.difference(x2))

result would be: set(['y', 'x', 'c', 'd', 'v'])

godot
  • 3,422
  • 6
  • 25
  • 42
1

Wouldn't a left join mean:

  • All elements from A (left)
  • plus all elements from B (right) that are in A

Like so, meaning in essence, the result is A?

If you want all elements of A that are not in B: c = a - b

If you want all elements that are in Aand B (intersection): c = a & b

timmwagener
  • 2,368
  • 2
  • 19
  • 27