在pycharm中打开CSV文件时出现错误

时间:2019-01-20 08:01:54

标签: python pandas pycharm

我正在使用 pycharm ,当我运行使用csv打开pandas文件的代码时,出现了不存在的错误。 我将csv文件保存在项目目录中,并使用pandas对其进行了命名。

import pandas as pd
df = pd.read_csv("E:\\students")
print(df)

运行代码时出现错误:

Traceback (most recent call last):   File "E:/untitled232/file1.py", line 2, in <module>
    df = pd.read_csv("E:\\students")   File "E:\untitled232\venv\lib\site-packages\pandas\io\parsers.py", line 678, in parser_f
    return _read(filepath_or_buffer, kwds)   File "E:\untitled232\venv\lib\site-packages\pandas\io\parsers.py", line 440, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)   File "E:\untitled232\venv\lib\site-packages\pandas\io\parsers.py", line 787, in __init__
    self._make_engine(self.engine)   File "E:\untitled232\venv\lib\site-packages\pandas\io\parsers.py", line 1014, in _make_engine
    self._engine = CParserWrapper(self.f, **self.options)   File "E:\untitled232\venv\lib\site-packages\pandas\io\parsers.py", line 1708, in __init__
    self._reader = parsers.TextReader(src, **kwds)   File "pandas\_libs\parsers.pyx", line 384, in pandas._libs.parsers.TextReader.__cinit__   File "pandas\_libs\parsers.pyx", line 695, in pandas._libs.parsers.TextReader._setup_parser_source FileNotFoundError: File b'E:\\students' does not exist

1 个答案:

答案 0 :(得分:0)

似乎我必须在名称后加上.csv