Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.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
将Excel文件从Python读入内存并将工作表传递给Pandas_Python_Excel_Pandas_Dataframe - Fatal编程技术网

将Excel文件从Python读入内存并将工作表传递给Pandas

将Excel文件从Python读入内存并将工作表传递给Pandas,python,excel,pandas,dataframe,Python,Excel,Pandas,Dataframe,我想读入一个excel文件的多张表格中的多个数据框 到目前为止,我使用: myfile = filename myfilecomplete = os.path.join(mypath,myfile) df_data=pd.read_excel(myfilecomplete, sheet_name='DATA',skiprows=4, indexcol=1,usecols="A:i") Excel文件中大约有10张表格需要阅读。因此,我将最后一行重复10次,以适应每张图纸:

我想读入一个excel文件的多张表格中的多个数据框

到目前为止,我使用:

myfile           = filename
myfilecomplete = os.path.join(mypath,myfile)
df_data=pd.read_excel(myfilecomplete, sheet_name='DATA',skiprows=4, indexcol=1,usecols="A:i")
Excel文件中大约有10张表格需要阅读。因此,我将最后一行重复10次,以适应每张图纸:

df_data2=pd.read_excel(myfilecomplete, sheet_name='Whatever',skiprows=3, indexcol=1,usecols="A:O")
等等

观察每一页的阅读方式(列和起始行)

现在,这个过程需要相当长的时间。excel文件不是非常大(大约3MB),只有大约1/3的表格有标题

我正试图找到加速这一进程的方法。等待10秒太多了,因为这个过程必须由用户连续运行

有什么想法吗? 我认为使用pd.read_excel,每次读取工作表时代码都会访问光盘,而将excel工作表加载到内存中并从中解析工作表似乎更符合逻辑。那会有帮助吗?你是怎么做到的

我还是个新手,但我听过很多关于并发和并行计算的东西,这对我有帮助吗


谢谢。

您可以使用
ExcelFile
一次读取整个文件,然后从中读取各个页面

xlFile = pd.ExcelFile(myfilecomplete)
df_data = pd.read_excel(xlFile, sheet_name='DATA',skiprows=4, indexcol=1,usecols="A:i")
df_data2 = pd.read_excel(xlFile, sheet_name='Whatever',skiprows=3, indexcol=1,usecols="A:O")

伟大的我的路=40秒,你的路=8秒