프로그래밍/Python
pandas dataframe을 csv 한글깨짐. Pandas df.to_csv("file.csv" encode="utf-8") still gives trash characters for minus sign
홍반장水_
2022. 2. 14. 14:17
반응형
Pandas df.to_csv("file.csv" encode="utf-8") still gives trash characters for minus sign
Pandas df.to_csv("file.csv" encode="utf-8") still gives trash characters for minus sign
I've read something about a Python 2 limitation with respect to Pandas' to_csv( ... etc ...). Have I hit it? I'm on Python 2.7.3 This turns out trash characters for ≥ and - when they appear in st...
stackoverflow.com
https://stackoverflow.com/questions/25788037/pandas-df-to-csvfile-csv-encode-utf-8-still-gives-trash-characters-for-min
pandas dataframe을 csv 형태로, to_csv
utf-8 encoding으로 저장하면
내용 중 한글이 깨지는 문제 발생
euc-kr 로 저장할 때는 문제 없음
df.to_csv('file.csv',encoding='euc-kr')
df.to_csv('file.csv',encoding='utf-8')
한글 깨짐
해결책: df.to_csv('file.csv',encoding='utf-8-sig')
windows 환경 (정확히는 win7)
Python 3.6.4 :: Anaconda custom (64-bit)
pandas==0.23.4
반응형