Python 2.7 Invalid syntax when running script from .csv file using pandas
Question: I am running a script with Python 2.7 using pandas to read from 2 csv files. I
keep getting "invalid syntax" error messages, particularly on line 6 and 8. I
can't figure out where is the problem, since line 6 is almost identical to
line 5 and there I don't get any error. Thanks very much for your help !

    
    
    import numpy as np
    import csv as csv
    import pandas as pd
    
    da = pd.read_csv('snp_rs.csv', index_col=(0,1), usecols=(0, 1), header=None,    converters = dict.fromkeys([0,1])
    db = pd.read_csv('chl.map.csv', index_col=(0,1), usecols=(0,1), header=None,    converters = dict.fromkeys([0,1])
    
    result = da.join(db, how='inner')
    x = result.to_csv('snp_rs_out.csv', header=None) # write as csv
    print x
    


Answer: As commented you need to close the parentheses around you `read_csv` call:

    
    
    da = pd.read_csv('snp_rs.csv', index_col=(0,1), usecols=(0, 1), header=None,    converters = dict.fromkeys([0,1])
    

It's missing a closing paren.

I find it a lot easier to write/read these if you split the lines:

    
    
    da = pd.read_csv('snp_rs.csv',
                     index_col=(0,1),
                     usecols=(0, 1),
                     header=None,
                     converters=dict.fromkeys([0,1])
    

then it's much clearer that a final `)` is missing.

