我尝试读取我已读写的csv文件,并使用Win10
中Visual Code.
下的pandas对数据帧进行了读写访问。
df1 = pd.read_csv("C:\\Users\\me\\Desktop\\Python\\Analytics\\in\\test_DS.csv", sep=';', header = None)
df1 = pd.read_csv(r"C:\Users\me\Desktop\Python\Analytics\in\test_DS.csv", sep=';', header = None)
df1 = pd.read_csv(r"C:/Users/me/Desktop/Python/Analytics/in/test_DS.csv", sep=';', header = None)
但是我仍然得到Error
:无法打开parsers.pyx
中找不到的C:/Users/me/Desktop/Python/Pandas/_libs/parsers.pyx.
文件
有人可以告诉我我在做什么错吗?
******************跟踪 为了实现回溯,我实现了:
except Exception:
print("Exception in user code:")
print("-"*60)
traceback.print_exc(file=sys.stdout)
print("-"*60)
我知道了
Exception in user code:
------------------------------------------------------------
Traceback (most recent call last):
File "pandas\_libs\parsers.pyx", line 1169, in pandas._libs.parsers.TextReader._convert_tokens
File "pandas\_libs\parsers.pyx", line 1299, in pandas._libs.parsers.TextReader._convert_with_dtype
File "pandas\_libs\parsers.pyx", line 1315, in pandas._libs.parsers.TextReader._string_convert
File "pandas\_libs\parsers.pyx", line 1553, in pandas._libs.parsers._string_box_utf8
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 10: invalid start byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\me\Desktop\Python\GPTW-Analytics\py\main.py", line 22, in <module>
df1 = pd.read_csv('C:/Users/me/Desktop/Python/GPTW-Analytics/in/test_DS.csv', sep=';')
File "C:\Users\me\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\io\parsers.py", line 702, in parser_f
return _read(filepath_or_buffer, kwds)
File "C:\Users\me\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\io\parsers.py", line 435, in _read
data = parser.read(nrows)
File "C:\Users\me\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\io\parsers.py", line 1139, in read
ret = self._engine.read(nrows)
File "C:\Users\me\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\io\parsers.py", line 1995, in read
data = self._reader.read(nrows)
File "pandas\_libs\parsers.pyx", line 899, in pandas._libs.parsers.TextReader.read
File "pandas\_libs\parsers.pyx", line 914, in pandas._libs.parsers.TextReader._read_low_memory
File "pandas\_libs\parsers.pyx", line 991, in pandas._libs.parsers.TextReader._read_rows
File "pandas\_libs\parsers.pyx", line 1123, in pandas._libs.parsers.TextReader._convert_column_data
File "pandas\_libs\parsers.pyx", line 1176, in pandas._libs.parsers.TextReader._convert_tokens
File "pandas\_libs\parsers.pyx", line 1299, in pandas._libs.parsers.TextReader._convert_with_dtype
File "pandas\_libs\parsers.pyx", line 1315, in pandas._libs.parsers.TextReader._string_convert
File "pandas\_libs\parsers.pyx", line 1553, in pandas._libs.parsers._string_box_utf8
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 10: invalid start byte
------------------------------------------------------------
答案 0 :(得分:1)
我今天也遇到了同样的问题,重新安装pandas和numpy并没有帮助。然后我意识到我的分隔符是错误的。解决该问题的方法已解决。值得检查吗?
此外,您的回溯使文件看起来好像已损坏;也许还要在此处发布文件顶部以进行调试。