Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. # We have dataframe A with column name
  2. # We have dataframe B with column name
  3. # I want to see rows in A with name Y such that there exists rows in B with name Y.
  4. # It's like set intersection.
  5. intersected = reduce(lambda x, y: x | (A['name'] == y), [False] + list(B['name']))
  6. intersection = A[intersected]
  7.  
  8. # other alternatives
  9. intersection = pd.merge(A, B, how='inner', on=['name'])
  10. intersection.dropna(inplace=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement