I've look at this answer: How can I selectively escape percent (%) in Python strings? and I believe my problem is different.
I'm trying to convert a percentage to decimal, but first I need to test if a percentage signs exists. My data is in a dataframe
. My code is:
df[i]=df[i].map(lambda x: float(x.strip('%'))/100 if '%' in x)
This gives me SyntaxError: invalid syntax