1def FormatPerc(x): # Create the function to be applied
2 perc = 0
3 x = str(x)
4
5 if '%' in x:
6 x = x.replace("%","")
7 perc = float(x)*0.001
8 else:
9 x = x.replace("%","")
10 perc = float(x)
11
12 return perc
13
14# in your pandas script:
15investments['WithdrawPercentage'] = investments['WithdrawPercentage'].apply(FormatPerc)
16# any values like "xx.x%" will now be formatted as 0.xxx