我正在尝试在jupyter noteboks中编写代码,该代码读取Excel文件并从中创建数据框。此问题的陷阱在于文件不在同一位置,但在不同的网络驱动器上。说,我的Python在C驱动器中运行,但是我的excel文件在M网络驱动器中。
我已经尝试过pd.read_excel(r'path')命令,但是它会引发错误-“没有这样的文件或目录”
答案 0 :(得分:0)
not sure if this is what you are looking for , and the syntax for jupyter notebooks is a little different, but try changing the path before reading the file?
import os
import pandas as pd
path = os.chdir(r"M:\path")
df = pd.read_excel('filename')