I have the following dataframe:
df1:
Revenue Earnings Date
Year
2017 43206832000 4608790000 2017-01-01
2018 43462740000 8928258000 2018-01-01
2019 44268171000 5001014000 2019-01-01
2020 43126472000 4770527000 2020-01-01
I am using an api to get the excahnge currency, the api is CurrencyConverter, the link is: https://pypi.org/project/CurrencyConverter/
I am trying to add a column to my dataframe to show me the exchange rate of that date, I used the method:
c.convert(100, 'EUR', 'USD', date=date(2013, 3, 21))
My code is:
c = CurrencyConverter()
earnings['exchange_rate'] = c.convert(1, 'BRL', 'USD', earnings['Date'])
print(earnings)
I get an answer that says:
TypeError: 'Series' objects are mutable, thus they cannot be hashed
I would like to get the following:
Revenue Earnings Date exchange_rate
Year
2017 43206832000 4608790000 2017-01-01 0.305
2018 43462740000 8928258000 2018-01-01 0.305
2019 44268171000 5001014000 2019-01-01 0.295
2020 43126472000 4770527000 2020-01-01 0.249