以下是我尝试在我的jupyter笔记本中运行的代码片段:
import os
#print(os.path.expanduser("~"))
import pandas as pd
data = pd.read_csv("C:\Users\sonaw\Data\dump4.csv")
print(data)
这是运行代码段时收到的错误消息:
FileNotFoundError Traceback (most recent call last)
<ipython-input-26-535fb23b20c4> in <module>()
1 import pandas as pd
2 data_filename = "dump4.csv"
----> 3 dataset = pd.read_csv("C:/Users/sonaw/Data/dump4.csv")
4 print(dataset.head())
~\Anaconda3\lib\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, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision)
--> 709 return _read(filepath_or_buffer, kwds)
~\Anaconda3\lib\site-packages\pandas\io\parsers.py in _read(filepath_or_buffer, kwds)
--> 449 parser = TextFileReader(filepath_or_buffer, **kwds)
~\Anaconda3\lib\site-packages\pandas\io\parsers.py in __init__(self, f, engine, **kwds)
--> 818 self._make_engine(self.engine)
~\Anaconda3\lib\site-packages\pandas\io\parsers.py in _make_engine(self, engine)
-> 1049 self._engine = CParserWrapper(self.f, **self.options)
~\Anaconda3\lib\site-packages\pandas\io\parsers.py in __init__(self, src, **kwds)
-> 1695 self._reader = parsers.TextReader(src, **kwds)
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.__cinit__()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source()`enter code here`
FileNotFoundError: File b'C:/Users/sonaw/Data/dump4.csv' does not exist
为什么我看到这个错误?可能是这个问题的根源是什么?
答案 0 :(得分:0)
谢谢大家......这个问题已经解决了。显然路径是正确的,但文件很大,需要正确命名user_cols&amp;在读取文件时输入low_memory = False。这让我可以读取文件。
答案 1 :(得分:0)
:/用户/图案/桌面/
尝试执行此操作将解决您的问题。