Pandas - read CSV with spanish characters

I have DataFrame which has column with spanish regions, when I import the .csv as following

df = pd.read_csv('...',delimiter=';',decimal=',')


And print the content of column, I see this: Castilla y Le�n.

I could not find a way how to fix it, but I am assuming there is smart way how to do it.

read_csv has an optional argument called encoding that deals with the way your characters are encoded.

You can give a try to:

df = pandas.read_csv('...', delimiter = ';', decimal = ',', encoding = 'utf-8')


Otherwise, you have to check how your characters are encoded (It is one of them).

You can read the doc of read_csv here

• The reason why I didn't convert my comment to an answer is because I didn't have an example which could be helpful to the OP. So, pl add an example if you can :) – Dawny33 Jun 22 '16 at 16:19
• I tried the encoding and with no success. In the end I solved it by changing the encoding on DB level, so it comes to Python clean. – HonzaB Jun 29 '16 at 8:39

The solution was posted in Stack Overflow

You need:

df.to_csv('file.csv',encoding='utf-8-sig')


When using MacOs try this:

df.to_csv('file.csv', encoding='maccentraleurope')


From: Python Codecs