Use an equality join to attach a user attribute to each transaction. A left join keeps a transaction even when its user has no matching record.

from chalkdf import DataFrame

tx = DataFrame({"user": ["a", "a", "b"], "amount": [12, 8, 30]})

users = DataFrame({"user": ["a"], "region": ["west"]})
tx.join(users, on=["user"], how="left").select("user", "amount", "region").order_by("amount").run()
#
userstring
amountint64
regionstring
1a8west
2a12west
3b30null

User b has no region in the lookup table. Use an inner join to keep only matches. If a key matches several right-hand rows, each match contributes a result row.

​
Match by time

For a rate that changes over time, use join_asof with the timestamp as on and the currency as by. With the backward strategy, a transaction takes the latest rate at or before its timestamp within that currency. Sort observations in time order and choose one rate per currency and timestamp to make ties unambiguous.

​
Look up the most recent rate

Here the time key is an integer minute. A payment at minute 3 uses the rate published at minute 1. A payment at minute 5 can use the rate published that same minute.

payments = DataFrame({"minute": [3, 5], "currency": ["USD", "USD"]})
rates = DataFrame({"minute": [1, 5], "currency": ["USD", "USD"], "rate": [10, 12]})
payments.join_asof(rates, on="minute", by="currency", strategy="backward").run()
#
minuteint64
currencystring
rateint64
13USD10
25USD12

A payment preceding the first rate for its currency has no match.

See DataFrame.join, DataFrame.join_asof.