We know pandas Reading of excel The normal way to file is pd.read_excel(file, sheetname), I think a lot of people read in this normal way .

actually ,sheetname It can be digital , For every one sheet Sort number of .

We use it python Run the efficiency analysis tool to look at different modes , How fast are they performing ?
 
import timeit import pandas as pd import time fpath =
r'F:\python_workspace\ case study \ Reptiles \ Margin Monitoring Center \ Interface design 2\ Settlement documents \xxxx_2018-07-12.xls' def
read1_1(fpath, num):     for i in range(num):         io =
pd.io.excel.ExcelFile(fpath)         data =pd.read_excel(io, sheetname=' Position details ')
        data2 =pd.read_excel(io, sheetname=' Transaction details ')         data2
=pd.read_excel(io, sheetname=' Transaction details ')         #data =pd.read_excel(io,
sheetname=4)         io.close() def read1_2(fpath, num):     for i in
range(num):         io = pd.io.excel.ExcelFile(fpath)         #data
=pd.read_excel(io, sheetname=' Position details ')         data =pd.read_excel(io,
sheetname=4)         data2 =pd.read_excel(io, sheetname=2)         data2
=pd.read_excel(io, sheetname=2)         io.close()      def read2_1(fpath,
num):     for i in range(num):         #io = pd.io.excel.ExcelFile(fpath)      
  data =pd.read_excel(fpath, sheetname=' Position details ')         data2
=pd.read_excel(fpath, sheetname=' Transaction details ')         data2 =pd.read_excel(fpath,
sheetname=' Transaction details ')         #data =pd.read_excel(io, sheetname=4)        
#io.close()               def read2_2(fpath, num):     for i in range(num):    
    data =pd.read_excel(fpath, sheetname=4)         data =pd.read_excel(fpath,
sheetname=2)         data =pd.read_excel(fpath, sheetname=2)                  
@profile def run(num):     read1_1(fpath, num)     read1_2(fpath, num)    
read2_1(fpath, num)     read2_2(fpath, num)           run(100)
Store the above code as test_pdread.py After the document , stay cmd Under the implementation :

kernprof -l -v test_pdread.py

Take a look at the execution results :
F:\python_workspace\ case study \ Reptiles \ Margin Monitoring Center \ Interface design 2>kernprof -l -v test_pdread.py Wrote
profile results to test_pdread.py.lprof Timer unit: 3.11018e-07 s Total time:
108.668 s File: test_pdread.py Function: run at line 49 Line # Hits Time Per
Hit % Time Line Contents
============================================================== 49 @profile 50
def run(num): 51 1 47338937 47338937.0 13.5 read1_1(fpath, num) 52 1 47416650
47416650.0 13.6 read1_2(fpath, num) 53 1 127432634 127432634.0 36.5
read2_1(fpath, num) 54 1 127205921 127205921.0 36.4 read2_2(fpath, num)
Obviously , Twice the execution speed .

First point to io The reading speed will be faster .

 

 

be careful : If one excel file , You just need to read the 1 individual sheet, Then all the operation time is basically the same . High efficiency here refers to multiple sheet Form .

Technology