Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> data = pd.read_csv("C:/Users/93037/Desktop/credit_card.csv") File "D:\python\lib\site-packages\pandas\io\parsers\readers.py", line 912, in read_csv return _read(filepath_or_buffer, kwds) File "D:\python\lib\site-packages\pandas\io\parsers\readers.py", line 577, in _read parser = TextFileReader(filepath_or_buffer, **kwds) File "D:\python\lib\site-packages\pandas\io\parsers\readers.py", line 1407, in __init__ self._engine = self._make_engine(f, self.engine) File "D:\python\lib\site-packages\pandas\io\parsers\readers.py", line 1679, in _make_engine return mapping[engine](f, **self.options) File "D:\python\lib\site-packages\pandas\io\parsers\c_parser_wrapper.py", line 93, in __init__ self._reader = parsers.TextReader(src, **kwds) File "pandas\_libs\parsers.pyx", line 548, in pandas._libs.parsers.TextReader.__cinit__ File "pandas\_libs\parsers.pyx", line 637, in pandas._libs.parsers.TextReader._get_header File "pandas\_libs\parsers.pyx", line 848, in pandas._libs.parsers.TextReader._tokenize_rows File "pandas\_libs\parsers.pyx", line 859, in pandas._libs.parsers.TextReader._check_tokenize_status File "pandas\_libs\parsers.pyx", line 2017, in pandas._libs.parsers.raise_parser_error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 0: invalid continuation byte
时间: 2023-08-01 22:12:13 浏览: 221
解决pandas read_csv 读取中文列标题文件报错的问题
这个错误是由于 Pandas 读取 CSV 文件时默认使用 `UTF-8` 编码,但是你的 CSV 文件使用的编码格式可能与此不同。你可以尝试指定正确的编码格式,例如:
```
data = pd.read_csv("C:/Users/93037/Desktop/credit_card.csv", encoding='gbk')
```
其中 `gbk` 是中文编码格式之一,你可以根据实际情况选择正确的编码格式。如果仍然存在问题,请检查 CSV 文件的编码格式是否正确,并尝试使用其他编码格式解决问题。
阅读全文