Reputation: 99
I have two dataframes:
a:
TransID Currency Amount
1 CAD 100
2 USD 90
b:
TransID Currency Amount
3 CAD 80
4 EUR 100
5 CAD 110
The conditions are if two TransIDs have a common currency and the amount in table a is less than the amount in table b print the output as a pair of the two, i.e. in this case the output should be -
(1,3)
Upvotes: 2
Views: 83
Reputation: 150735
Shouldn't it be (1,5)
, (1,3)
has Amount_a > Amount_b
?
(dfa.merge(dfb, on='Currency')
.query('Amount_x < Amount_y')
.filter(like='TransID')
.values
)
Output:
array([[1, 5]], dtype=int64)
Upvotes: 2