當文件夾中存在文件時,出現文件不存在的錯誤,請問我在哪裏犯了錯誤?熊貓無法聚合
pd.DataFrame.from_csv
我收到如下所示的錯誤。
Traceback (most recent call last):
File "main.py", line 194, in <module>
start_path+end_res)
File "/Users/admin/Desktop/script/mergeT.py", line 5, in merge
df_peak = pd.DataFrame.from_csv(peak_score, index_col = False, sep='\t')
File "/Library/Python/2.7/site-packages/pandas/core/frame.py", line 1231, in from_csv
infer_datetime_format=infer_datetime_format)
File "/Library/Python/2.7/site-packages/pandas/io/parsers.py", line 645, in parser_f
return _read(filepath_or_buffer, kwds)
File "/Library/Python/2.7/site-packages/pandas/io/parsers.py", line 388, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "/Library/Python/2.7/site-packages/pandas/io/parsers.py", line 729, in __init__
self._make_engine(self.engine)
File "/Library/Python/2.7/site-packages/pandas/io/parsers.py", line 922, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "/Library/Python/2.7/site-packages/pandas/io/parsers.py", line 1389, in __init__
self._reader = _parser.TextReader(src, **kwds)
File "pandas/parser.pyx", line 373, in pandas.parser.TextReader.__cinit__ (pandas/parser.c:4175)
File "pandas/parser.pyx", line 667, in pandas.parse**strong text**r.TextReader._setup_parser_source (pandas/parser.c:8440)
IOError: File results\scoring\fed\score_peak.txt does not exist
我已經嘗試的路徑設置爲確切的文件 例如
第一個錯誤:腳本的縮進錯誤。然後:backslaches而不是斜槓。可能您使用的是過時的文件,可能是在Windows中配置的。 – user3159253
像@ user3159253表示你需要在函數'def'後面縮進所有內容,否則文件路徑不會被改變。 –
@ user3159253您的意思是我導入數據,如peak_score ='\ Users \ admin \ Desktop \ peak_score.txt'?是的,它是基於Windows,現在我使用Mac –