Pandas DataFrame: remove � (unknown-character) from strings in rows

Viewed 4266

I have read a csv file into python 2.7 (windows machine). Sales Price column seems to be mixture of string and float. And some rows contains a euro symbol €. Python sees € as �.

df = pd.read_csv('sales.csv', thousands=',')
print df

Gender  Size    Color   Category    Sales Price
Female  36-38   Blue    Socks       25
Female  44-46   Pink    Socks       13.2
Unisex  36-38   Black   Socks      � 19.00
Unisex  40-42   Pink    Socks      � 18.50
Female  38      Yellow  Pants      � 89,00
Female  43      Black   Pants      � 89,00

I was under the assumption that a simple line with replace will solve it

df=df.replace('\�','',regex=True).astype(float)

But I got encoding error

SyntaxError: Non-ASCII character

Would appreciate hearing your thoughts on this

2 Answers
Related