【发布时间】:2017-09-14 20:44:34
【问题描述】:
我有两列的 DataFrame:
col1 | col2
20 EUR
31 GBP
5 JPY
我可能有 10000 行这样的行
如何快速将货币转换为英镑的基础货币?
我应该使用easymoney吗? 我知道如何将转换应用于单行,但我不知道如何快速遍历所有行。
编辑: 我想申请:
def convert_currency(amount, currency_symbol):
converted = ep.currency_converter(amount=1000, from_currency=currency_symbol, to_currency="GBP")
return converted
df.loc[df.currency != 'GBP', 'col1'] = convert_currency(currency_data.col1, df.col2
)
但它还没有工作。
【问题讨论】:
-
覆盖上述行,类似于
df['col1'] = formulae*df['col1']。我想是的 -
有没有快速的选项来使用 pandas 获取货币比率?我有 30 种不同的货币是什么?
-
你们有汇率吗?以哪种形式?
-
我没有。我想我可以使用easymoney。