Python3.x,熊猫,CSV,UTF-8的错误

问题描述:

我试图用大熊猫并获得以下错误消息导入数据集:Python3.x,熊猫,CSV,UTF-8的错误

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 10: invalid start byte

我读到编码,并试图把它作为

df=pd.read_csv("file.csv",encoding="ISO-xxxx") 

它显示错误为无效语法。

我分享链接到我的数据,如果你们想看看:https://www.kaggle.com/venkatramakrishnan/india-water-quality-data

+0

您可以显示 “无效语法” 错误的追踪? – lenz

+1

请将该数据集修剪至再现问题的最小数据集,然后将其编辑到问题中。如果删除上半部分或下半部分,问题是否仍然存在?它可以缩小到一行吗?除非问题本身能够显示问题,否则问题就会脱离主题,因为我们希望问题能够在未来得到证明(在您从外部删除/修改文件之后)。 – halfer

+0

无效语法错误现在被删除,我检查了回溯并自行解决。 –

import pandas as pd 

df = pd.read_csv('IndiaAffectedWaterQualityAreas.csv',encoding = 'latin-1') 

上面的代码写在蟒蛇3.6大熊猫“0.20.1解决方案之一'

为什么会出现此问题?

There are some special character which by default utf-8 is cannot be used to decode. if you have the raw data,try making the csv using pandas with the following code:

df.to_csv('IndiaAffectedWaterQualityAreas.csv',encoding = 'latin-1')