前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xd6 in position 19: invalid continuation byte

UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xd6 in position 19: invalid continuation byte

作者头像
Java架构师必看
发布2021-08-10 11:25:53
1.1K0
发布2021-08-10 11:25:53
举报
文章被收录于专栏:Java架构师必看

UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xd6 in position 19: invalid continuation byte

强烈推介IDEA2020.2破解激活,IntelliJ IDEA 注册码,2020.2 IDEA 激活码

解決方案:

 修改字符集,从 utf-8改成gbk 。

代码语言:javascript
复制
import pandas as pd
df = pd.read_csv(filepath_or_buffer='E:\\tmp\\2\\result.csv',encoding='utf-8',index_col=0,header=2)
print(df)

問題如下:

Traceback (most recent call last):   File "E:/workspace/nlp_workspace/nlpdata/tmp/zhijian0824.py", line 2, in <module>     df = pd.read_csv(filepath_or_buffer='E:\\tmp\\2\\result.csv',encoding='utf-8',index_col=0,header=2)   File "D:\soft\developSoft\Anaconda3\envs\test36\lib\site-packages\pandas\io\parsers.py", line 686, in read_csv     return _read(filepath_or_buffer, kwds)   File "D:\soft\developSoft\Anaconda3\envs\test36\lib\site-packages\pandas\io\parsers.py", line 452, in _read     parser = TextFileReader(fp_or_buf, **kwds)   File "D:\soft\developSoft\Anaconda3\envs\test36\lib\site-packages\pandas\io\parsers.py", line 936, in __init__     self._make_engine(self.engine)   File "D:\soft\developSoft\Anaconda3\envs\test36\lib\site-packages\pandas\io\parsers.py", line 1168, in _make_engine     self._engine = CParserWrapper(self.f, **self.options)   File "D:\soft\developSoft\Anaconda3\envs\test36\lib\site-packages\pandas\io\parsers.py", line 1998, in __init__     self._reader = parsers.TextReader(src, **kwds)   File "pandas\_libs\parsers.pyx", line 516, in pandas._libs.parsers.TextReader.__cinit__   File "pandas\_libs\parsers.pyx", line 690, in pandas._libs.parsers.TextReader._get_header   File "pandas\_libs\parsers.pyx", line 884, in pandas._libs.parsers.TextReader._tokenize_rows   File "pandas\_libs\parsers.pyx", line 2013, in pandas._libs.parsers.raise_parser_error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd6 in position 19: invalid continuation byte

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档