61
39

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pandasのread_csvでUnicodeDecodeError

Last updated at Posted at 2016-11-01

#エラー内容
pandasのread_csvを行ったところ、エラーで読み込みできませんでした。

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

エラーメッセージ

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

#対応方法
encoding='cp932'をつけたらうまくいきました。

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

参考ページ

pandasでread_csv時にUnicodeDecodeErrorが起きた時の対処 (pd.read_table())
のコメントを参考にさせていただきました。

ありがとうございました。

61
39
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
61
39

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?