I have a dataframe which looks like this
Currency Amount Country
EUR 12.06 France
USD 10.23 USA
INR 122.17 India
INR 422.01 India
USD 8.06 USA
I have a function which would take currency name i.e. Currency column and use Amount to convert to a common currency
def convert_an_amount(amount,curr,target_currency):
if curr in c.currencies:
return c.convert(amount, curr , target_currency)
return np.nan
What I want to do is create the column of our dataframe
def convert_to_common(amount,curr_name,target_curr):
currency_coverted_variable -
... required code ...
I would like to have the following dataframe
Currency Amount Country Common Currency(EUR)
EUR 12.06 France x
USD 10.23 USA x
INR 122.17 India x
INR 422.01 India x
USD 8.06 USA x
Is there any way to code this function? I am using a library which would convert the value in the function but how to facilitate the creation of the dataframe?
The condition for c.convert is that it only converts one value at a time!