3
1

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 3 years have passed since last update.

【備忘録】Pandasのto_csv()で文字化けしたCSVを吐いてしまう

Posted at

#問題

久しぶりに,PandasでCSVを出力させたら,文字化けしてしまいました.

手順としては,以下のようなことをしていました.

CSV(UTF-8) -> Pandasで処理 -> UTF-8で出力

文字コードがあっているはずなのに,文字化けしてしまいました.

#解決方法

df.to_csv('output.csv',encoding='utf-8_sig')

出力する際に,utf-8ではなく,utf-8_sigで出力したら文字化けしなくなりました.

3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?