I have a dataframe like this:
currency currency_value amount curr_fin
0 EUR 0.839398 20.0 USD
1 GBP 0.751034 20.0 USD
2 AUD 1.361525 5.1 EUR
3 CAD 1.307768 3.5 USD
4 JPY 105.717997 8.0 GBP
whereas 'currency' and 'currency_value' are the forex references for the conversion against USD (USD is set to 1).
I want to convert the values in the 'amount' columns when the respective currency in 'curr_fin' is different from USD, because USD doesn't have to be converted. Please note that 'amount' and 'curr_fin' columns are much longer than 'currency' and 'currency_value' columns.
I transformed the forex reference into a dictionary for the iteration and then converted the values to list but probably it wasn't necessary:
curr_dict = dict(zip(df['currency'], df['currency_value']))
amounts = df['amount']
lists = list(curr_dict.values())
but I got problems for the iterations, that it's not working. How is it possible to do such operation between columns?
for forex in lists:
if df['currency'] == df['curr_fin']:
df['amount'] / df['currency']
print(forex)