Learner Algorithm Learner Algorithm - 1 year ago 95
Python Question

panda cannot converge

I get error that a file does not exist while I have the file there in the folder, would you please tell me where I am making a mistake ?


I am getting an error shown below.

Traceback (most recent call last):
File "main.py", line 194, in <module>
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
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__
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

I have tried to set a path to the exact file
for example

Answer Source

As per documentation of pandas 0.19.1 pandas.DataFrame.from_csv does not support index_col = False. Try to use pandas.read_csv instead (with the same parameters). Also make sure you are using the up to date version of pandas.

See if this works:

import pandas as pd
def merge(peak_score, profile_score, res_file):
    df_peak = pd.read_csv(peak_score, index_col = False, sep='\t')
    df_profile = pd.read_csv(profile_score, index_col = False, sep='\t')
    result = pd.concat([df_peak, df_profile], axis=1)
    print result.head()
    test = []
    for a,b in zip(result['prot_a_p'],result['prot_b_p']):
        if a == b:
    result = result[result['test']==0] 
    del result['test']
    result = result.fillna(0)

if __name__ == '__main__':

Regarding the path issue when changing from Windows to OS X:

In all flavours of Unix, paths are written with slashes /, while in Windows backslashes \ are used. Since OS X is a descendant of Unix, as other users have correctly pointed out, when you change there from Windows you need to adapt your paths.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download