Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 0-1: invalid continuation byte [duplicate]

Tags:

python

pandas

I am trying to try pandas methods in a csv file I've made which looks like:

Location  Time    Number
Seoul     Nov.11     5
Jinju      dec.22    2
wpg                  3
          june.6     2

something like this. It is giving me an error message in the title. How can I fix this and what position is it referring exactly?

like image 377
haneulkim Avatar asked Dec 24 '22 00:12

haneulkim


1 Answers

According to https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html , you can add encoding parameter when reading the CSV file. I suggest you add "utf-8" or "ISO-8859-1".

pandas.read_csv(yourfile, encoding="utf-8")

or

pandas.read_csv(yourfile, encoding="ISO-8859-1")
like image 89
taipei Avatar answered Jan 05 '23 00:01

taipei