【问题标题】:Reading XLSX data from subfolders on desktop从桌面子文件夹中读取 XLSX 数据
【发布时间】:2021-01-15 08:15:06
【问题描述】:

我正在尝试使用我桌面上的子文件夹中的 pandas 和 jupyter notebook 将 excel 文件读入数据框。该文件位于我桌面上名为“Data”的文件夹、子文件夹“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'

【问题讨论】:

    标签: python excel pandas jupyter-notebook readfile


    【解决方案1】:

    尝试使用双反斜杠而不是单正斜杠。我总是使用双反斜杠,它对我有用。

    你的代码应该是这样的:

    df_customers = pd.read_excel (r"C:\\Users\\Zach\\Desktop\\Data\\KN-Data\\New-Files\\Customers.xlsx")
    

    【讨论】:

    • 对于每一个斜线?
    • @ZachCornelison S
    • 你使用了反斜杠吗?
    • 是的,我试过反斜杠和正斜杠,单斜杠和双斜杠
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-18
    • 2015-12-10
    • 2022-11-17
    相关资源
    最近更新 更多