我有一列“货币”和另一列“金额”。“currency”列包含以下格式的对象: USD、EUR、SEK、AUD等。
我想通过转换所有其他货币来将所有'amount‘值转换为USD,并在新列中打印新的转换,但我在这一点上遇到了困难:
import pandas as pd
from forex_python.converter import CurrencyRates
c = CurrencyRates()
y = ['currency']
x = ['amount']
for column in df['amount']:
c.get_rate('USD', x)我是否应该将每个货币符号与相应的金额联系起来?
发布于 2020-09-06 05:20:04
如果你有一个df,那么这就是遍历行的方法:
for index, row in df.iterrows():
c.get_rate(row['currency'], row['amount'])我不熟悉get_rate函数。
https://stackoverflow.com/questions/63758217
复制相似问题