Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在for循环中解析包含多个工作表的Excel文件_Excel_Pandas_Parsing - Fatal编程技术网

如何在for循环中解析包含多个工作表的Excel文件

如何在for循环中解析包含多个工作表的Excel文件,excel,pandas,parsing,Excel,Pandas,Parsing,我想在Python中导入一个包含4个工作表的Excel文件,对于每个工作表,我需要一个数据框 我试着这样做: data=ExcelFile(path) sheets=data.sheet_names for i in range(0,4): df[i]=pd.read_excel(path,sheet_name=i) sales=df[0] customers=df[1] dates=df[2] employees=df[3] 代码的las部分是我想要自动化的部分 谢谢 我试过这个

我想在Python中导入一个包含4个工作表的Excel文件,对于每个工作表,我需要一个数据框

我试着这样做:

data=ExcelFile(path)
sheets=data.sheet_names

for i in range(0,4):
  df[i]=pd.read_excel(path,sheet_name=i)

sales=df[0]
customers=df[1]
dates=df[2]  
employees=df[3]
代码的las部分是我想要自动化的部分

谢谢

我试过这个:

data = pd.ExcelFile("/content/data.ods")
sales = pd.read_excel(data, 'Sheet1')
customers = pd.read_excel(data, 'Sheet2')
dates = pd.read_excel(data, 'Sheet3')
employees = pd.read_excel(data, 'Sheet4')

sales.head()
customers.head()
dates.head()
employees.head()
注意:“data.ods”是我创建的文件,用于尝试查看-指定多个工作表名称并获得
DataFrame
的dict。