Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # We have dataframe A with column name
- # We have dataframe B with column name
- # I want to see rows in A with name Y such that there exists rows in B with name Y.
- # It's like set intersection.
- intersected = reduce(lambda x, y: x | (A['name'] == y), [False] + list(B['name']))
- intersection = A[intersected]
- # other alternatives
- intersection = pd.merge(A, B, how='inner', on=['name'])
- intersection.dropna(inplace=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement