I would like to implement something like the following code. It create a new column notional_amount_jpy
in the same dataframe based on values from other columns in the same dataframe:
if df2['quoted_currency'] == 'JPY':
df2['notional_amount_jpy'] = df2['executed_price'] * df2['quantity']
elif df2['quoted_currency'] == 'USD':
df2['notional_amount_jpy'] = df2['executed_price'] * df2['quantity'] / df_rates['value']
else:
df2['notional_amount_jpy'] = (df2['executed_price'] * df2['quantity']) * df2['quoted_value'] / df_rates['value']
But I receive the following error:
Traceback (most recent call last):
File "/Users/de/source/GitHub/market_risk/mark_to_mar/src/code/mark_to_mar.py", line 107, in <module>
if df2['quoted_currency'] == 'JPY':
File "/Users/de/Library/Python/3.7/lib/python/site-packages/pandas/core/generic.py", line 1556, in __nonzero__
self.__class__.__name__
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Any help would be very appreciated.