我正在尝试使用Pandas和Jupyter Notebook从桌面上的子文件夹将Excel文件读取到数据框中。该文件在我的桌面上的文件夹中,该文件夹名为“数据”,子文件夹“ KN-Data”,子文件夹“ New-Files”,文件名为“ Customers.xlsx”。
这是我正在尝试的代码:
df_customers = pd.read_excel (r"C:/Users/Zach/Desktop/Data/KN-Data/New-Files/Customers.xlsx")
错误是
[Errno 2] No such file or directory: 'C:/Users/Zach/Desktop/Data/KN-Data/New-Files/Customers.xlsx'
答案 0 :(得分:0)
尝试使用双反斜杠而不是单正斜杠。我总是使用双反斜杠,它对我有用。
这是您的代码的外观:
df_customers = pd.read_excel (r"C:\\Users\\Zach\\Desktop\\Data\\KN-Data\\New-Files\\Customers.xlsx")