개발/Python

구글 코랩 판다스 read_csv 인코딩 오류

강서버 2024. 2. 17. 19:56
728x90
반응형

import pandas as pd

 

df = pd.read_csv('sample.csv')

 

---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
<ipython-input-10-1f009496a509> in <cell line: 1>()
----> 1 df = pd.read_csv('sample.csv')

10 frames
/usr/local/lib/python3.10/dist-packages/pandas/_libs/parsers.pyx in pandas._libs.parsers.raise_parser_error()

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc7 in position 0: invalid continuation byte

 

 

[ 해결 ]

encoding='cp949' 추가

 

df = pd.read_csv('sample.csv', encoding='cp949')

 

728x90
반응형