0

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)
2
  • What should be the ideal output? Please show how it looks like in DataFrame? Commented Feb 10, 2020 at 9:38
  • Gòtic and Montjuïc should be Commented Feb 10, 2020 at 9:50

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

For me too in Python 2.7 thank you so much buddy, you saved my life

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.