我正在使用 CSV 文件中的销售数据集。当我尝试使用 pandas read_csv 方法加载此数据集时,出现错误,UnicodeDecodeError: 'ascii' codec can't decode byte 0xae in position 16: ordinal not in range(128)我不知道如何解决此问题。我搜索它并得到了 这个链接,仍然无法解决我的问题。我尝试了以下
import pandas as pd
sales=pd.read_csv("Superstore-Sales.csv")
sales.head(5)
这是完整的错误
---------------------------------------------------------------------------
UnicodeDecodeError Traceback (most recent call last)
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._convert_tokens()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._convert_with_dtype()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._string_convert()
pandas/_libs/parsers.pyx in pandas._libs.parsers._string_box_utf8()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xae in position 16: invalid start byte
During handling of the above exception, another exception occurred:
UnicodeDecodeError Traceback (most recent call last)
<ipython-input-50-c100e90b0440> in <module>
1 import pandas as pd
2
----> 3 sales=pd.read_csv("Superstore-Sales.csv")
4 sales.head(5)
700 skip_blank_lines=skip_blank_lines)
701
--> 702 return _read(filepath_or_buffer, kwds)
703
704 parser_f.__name__ = name
D:\Anacoda\lib\site-packages\pandas\io\parsers.py in _read(filepath_or_buffer, kwds)
433
434 try:
--> 435 data = parser.read(nrows)
436 finally:
437 parser.close()
拉丁的传说
拉风的咖菲猫
相关分类