I have two dataframes, one called order_values & the other fx_rates. They look like below.
What I need to do is convert the value_loc value in the order_values dataframe into EUR's using the fx_rates dataframe.
In reality I won't know how many different currency there are & its likely to be more than shown below.
My current solution I believe is far from optimal. I loop through each different currency (i.e. USD, JPY etc) and merge that currency column (EURUSD, EURJPY) to the order_values dataframe & perform the calculation to convert the value_loc into value_eur & then drop the currency column from the order_values dataframe.
order_values
order_num value_loc currency date
1 2,345 USD 2-12-2021
2 104 EUR 2-12-2021
3 20,000 JPY 2-15-2021
4 550 USD 3-06-2021
fx_rates
date pair rate
2-12-2021 EURUSD 1.5
2-12-2021 EURJPY 5
2-12-2021 EUREUR 1
...
3-06-2021 EURUSD 1.56
3-06-2021 EURJPY 5.6
3-06-2021 EUREUR 1