Nov-19-2020, 12:17 PM
(This post was last modified: Nov-19-2020, 01:32 PM by calvinsomething.)
(SOLVED)
I've found similar problems to what I am having on stackoverflow, but nothing that solves what I'm dealing with.
I'm trying to remove the Euro sign as well as convert M and K amounts to 1000000 and 1000 respectively. Parts of this code seems to work individually, but I have to execute it all at once so that the single function can determine whether the amount has an 'M' or 'K' before removing it from the value, so that it can convert it to a float afterwards and still add the same amount of zeroes.
Here is the latest iteration of what I'm trying to do in code:
Thank you for anyone who can help me with this!
I've found similar problems to what I am having on stackoverflow, but nothing that solves what I'm dealing with.
I'm trying to remove the Euro sign as well as convert M and K amounts to 1000000 and 1000 respectively. Parts of this code seems to work individually, but I have to execute it all at once so that the single function can determine whether the amount has an 'M' or 'K' before removing it from the value, so that it can convert it to a float afterwards and still add the same amount of zeroes.
Here is the latest iteration of what I'm trying to do in code:
Quote:def fix(x):
if 'M' in x:
return float(x.replace('[€M]', '', regex=True))*10000000
if 'K' in x:
return float(x.replace('[€K]', '', regex=True))*10000
df1 = df[['Name', 'Value', 'Wage']]
df1.apply(fix)
df1.head(6)
Thank you for anyone who can help me with this!
