I have a dataframe with different currencies.
I'm creating an if formula to apply to a specific column and give me the results in another column:
Code:
def CurConv(x):
if rst[rst["Currency"]=="Botswana Pula(P)"]:
return x*0.094
elif rst[rst["Currency"]=="Brazilian Real(R$)"]:
return x*0.2
elif rst[rst["Currency"]=="Dollar($)"]:
return x
elif rst[rst["Currency"]=="Emirati Diram(AED)"]:
return x*0.27
elif rst[rst["Currency"]=="Indian Rupees(Rs.)"]:
return x*0.014
elif rst[rst["Currency"]=="Indonesian Rupiah(IDR)"]:
return x*0.000070
elif rst[rst["Currency"]=="NewZealand($)"]:
return x*0.71
elif rst[rst["Currency"]=="Pounds(å£)"]:
return x*1.41
elif rst[rst["Currency"]=="Qatari Rial(QR)"]:
return x*0.27
elif rst[rst["Currency"]=="Rand(R)"]:
return x*0.073
elif rst[rst["Currency"]=="Sri Lankan Rupee(LKR)"]:
return x*0.0051
elif rst[rst["Currency"]=="Turkish Lira(TL)"]:
return x*0.12
else:
return "NaN"
rst["USD"]=rst.AverageCostfortwo.apply(CurConv)
But I keep getting this error:"ValueError: The truth value of a DataFrame is ambiguous"