M. Mariscal
M. Mariscal

Reputation: 1328

How to avoid unicode errors from DataFrame to CSV?

Cannot get rid of unicode erros, how do i deal with them?

I'm using Dataframe (to_csv method) but the problem it shows on CSV the following:

Gòtic
Montjuïc

How to avoid it in Dataframes? Python 2.7 + Pandas

I'm using:

# encoding=utf8

I've tried:

.encode('utf-8')
u''.join(variable)

Upvotes: 0

Views: 183

Answers (1)

ManojK
ManojK

Reputation: 1640

Try this, change the encoding to latin-1

df.to_csv('your_csv_name.csv', encoding = 'latin-1')

output:

Gòtic
Montjuïc

Works fine for me in Python 3.7

Upvotes: 2

Related Questions