This seems very simple but I just can't figure it out.
I have a dataframe with an amount column in GBpence, Euro and USD. I need a new column with the amount in GBP, the only way I can think of doing this is to first convert the amount field to string, separate the amount from the currency sign and then use numpy to perform a conditional calculation.
df = pd.DataFrame({'date': ['2018-11-22','2018-11-23','2018-11-24'],
'amount': ['3.80p','$4.50','\N{euro sign}3.40'],
'usd-gbp':['0.82','0.83','0.84'],
'eur-gbp':['0.91','0.92','0.93']})
I am trying to convert the amount column to string so I can extract the currency and float amount but it just converts all the rows into the same string.
df['new'] = str(df['amount'])
Expected output would just be the amount values in string format so I can perform slicing on them.
Any help would be appreciated. Thanks.


