更新的代码:
file_name2 =r'C:\Users\Trading\Desktop\scott\initialTrades.csv'
df=pd.read_excel(file_name2)
print (df)
这将返回错误XLRDError。
file_name2 =r'C:\Users\Trading\Desktop\scott\initialTrades.xlsx'
df=pd.read_excel(file_name2)
print (df)
这将返回错误:FileNotFoundError。
file_name ='C:\ Users \ Trading \ Desktop \ scott' file_double =“ C:\ Users \ Trading \ Desktop \ scott”
我把两个\而不是\放在python replace single backslash with double backslash上,指出要摆脱(unicode错误)'unicodeescape'
我错过了哪一步?
这是我其余的代码:
sheet =initialTrades #I also tried 'initialTrades'
df = pd.read_excel(io=file_double, sheet_name=sheet)
print(df.head(5)) # print first 5 rows of the dataframe