[PYTHON] UnicodeDecodeError in pandas read_csv

error contents

When I did read_csv of pandas, it could not be read due to an error.

sample.py


import pandas as pd
df = pd.read_csv("hoge.csv")

Error message

UnicodeDecodeError:'utf-8' codec can't decode byte 0x95 in position 0: invalid start byte

How to respond

I added ʻencoding ='cp932'` and it worked.

sample.py


import pandas as pd
df = pd.read_csv("hoge.csv",encoding='cp932')

Reference page

What to do when UnicodeDecodeError occurs during read_csv in pandas (pd.read_table ()) I referred to the comments from.

Thank you very much.

Recommended Posts

UnicodeDecodeError in pandas read_csv
What to do when UnicodeDecodeError occurs during read_csv in pandas (pd.read_table ())
Learn Pandas in 10 minutes
Header shifts in read_csv () and read_table () of Pandas
Resolve UnicodeDecodeError in kivy JsonStore
Swap columns in pandas dataframes
I get a UnicodeDecodeError in mecab-python3
Create dummy variables in pandas (get_dummies)
How to write soberly in pandas
Features of pd.NA in pandas 1.0.0 (rc0)
Etosetra related to read_csv of Pandas
Pandas
Grammar summary often used in pandas
What to do if "Unnamed: 0" is added in to_csv-> read_csv in pandas
Ignore # line and read in pandas
UnicodeDecodeError occurs in pip (Windows environment)
Bar graph display in pandas (basic edition)
Load csv with duplicate columns in pandas
Summary of methods often used in pandas
Get the top nth values in Pandas
Precautions when using for statements in pandas
How to reassign index in pandas dataframe
[Python] Pandas to fully understand in 10 minutes
RDS data via stepping stones in Pandas
Processing memos often used in pandas (beginners)
How to read CSV files in Pandas
Adding Series to columns in python pandas
Working with 3D data structures in pandas
Is there NaN in the pandas DataFrame?