在 python 上找不到用于导入 csv 的文件。文件路径正确,一切都已安装
File Not Found on python for importing a csv. The file path is correct and everything is installed
我已经安装了 pandas 并且这几天一直在努力解决这个问题。文件路径是正确的,我什至试过 copy/pasting 文件路径。我正在通过 Anaconda 在 Mac 上使用 Jupyter Notebook(不确定这是否有所作为。我已在此处附上代码:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-3-2e4763966abb> in <module>
----> 1 df1 = pd.read_csv("C:/Users/snerbs/Desktop/PYTHON/Testing_Statistical_Hypotheses/Section2/Goats50.csv")
/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision)
674 )
675
--> 676 return _read(filepath_or_buffer, kwds)
677
678 parser_f.__name__ = name
/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
446
447 # Create the parser.
--> 448 parser = TextFileReader(fp_or_buf, **kwds)
449
450 if chunksize or iterator:
/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py in __init__(self, f, engine, **kwds)
878 self.options["has_index_names"] = kwds["has_index_names"]
879
--> 880 self._make_engine(self.engine)
881
882 def close(self):
/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py in _make_engine(self, engine)
1112 def _make_engine(self, engine="c"):
1113 if engine == "c":
-> 1114 self._engine = CParserWrapper(self.f, **self.options)
1115 else:
1116 if engine == "python":
/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py in __init__(self, src, **kwds)
1889 kwds["usecols"] = self.usecols
1890
-> 1891 self._reader = parsers.TextReader(src, **kwds)
1892 self.unnamed_cols = self._reader.unnamed_cols
1893
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.__cinit__()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source()
FileNotFoundError: [Errno 2] File C:/Users/snerbs/Desktop/PYTHON/Testing_Statistical_Hypotheses/Section2/Goats50.csv does not exist: 'C:/Users/snerbs/Desktop/PYTHON/Testing_Statistical_Hypotheses/Section2/Goats50.csv'
提前致谢!!
你确定路径正确吗?通过运行笔记本单元格上的以下内容检查文件是否在您认为的位置。
!ls path_to_folder_with_csv
输出应包含您的文件。此外,您应该 post 代码,而不是图片链接。
我已经安装了 pandas 并且这几天一直在努力解决这个问题。文件路径是正确的,我什至试过 copy/pasting 文件路径。我正在通过 Anaconda 在 Mac 上使用 Jupyter Notebook(不确定这是否有所作为。我已在此处附上代码:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-3-2e4763966abb> in <module>
----> 1 df1 = pd.read_csv("C:/Users/snerbs/Desktop/PYTHON/Testing_Statistical_Hypotheses/Section2/Goats50.csv")
/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision)
674 )
675
--> 676 return _read(filepath_or_buffer, kwds)
677
678 parser_f.__name__ = name
/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
446
447 # Create the parser.
--> 448 parser = TextFileReader(fp_or_buf, **kwds)
449
450 if chunksize or iterator:
/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py in __init__(self, f, engine, **kwds)
878 self.options["has_index_names"] = kwds["has_index_names"]
879
--> 880 self._make_engine(self.engine)
881
882 def close(self):
/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py in _make_engine(self, engine)
1112 def _make_engine(self, engine="c"):
1113 if engine == "c":
-> 1114 self._engine = CParserWrapper(self.f, **self.options)
1115 else:
1116 if engine == "python":
/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py in __init__(self, src, **kwds)
1889 kwds["usecols"] = self.usecols
1890
-> 1891 self._reader = parsers.TextReader(src, **kwds)
1892 self.unnamed_cols = self._reader.unnamed_cols
1893
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.__cinit__()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source()
FileNotFoundError: [Errno 2] File C:/Users/snerbs/Desktop/PYTHON/Testing_Statistical_Hypotheses/Section2/Goats50.csv does not exist: 'C:/Users/snerbs/Desktop/PYTHON/Testing_Statistical_Hypotheses/Section2/Goats50.csv'
提前致谢!!
你确定路径正确吗?通过运行笔记本单元格上的以下内容检查文件是否在您认为的位置。
!ls path_to_folder_with_csv
输出应包含您的文件。此外,您应该 post 代码,而不是图片链接。