sklearn筆記-FileNotFoundError

問題描述:
執行代碼:data = pd.read_csv(r"‪F:\data_sklearn\data_titanic.csv", index_col = 0)
報錯:

FileNotFoundError Traceback (most recent call last)
in
----> 1 data = pd.read_csv(r"‪F:\data_sklearn\data_titanic.csv", index_col = 0)
2 # data = pd.read_csv(r"F:\data_sklearn\data_titanic.csv", index_col = 0)
3 data.head()
4 data.info()

D:\Anaconda3\envs\sklearn\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, 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

D:\Anaconda3\envs\sklearn\lib\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:

D:\Anaconda3\envs\sklearn\lib\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):

D:\Anaconda3\envs\sklearn\lib\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”:

D:\Anaconda3\envs\sklearn\lib\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 ‪F:\data_sklearn\data_titanic.csv does not exist: ‘\u202aF:\data_sklearn\data_titanic.csv’

解決方案:問題出現在手動複製windows文件路徑,pandas解析時會出現亂碼,只需要手動輸入路徑就可以解決這個問題.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章