@@ -2341,10 +2341,10 @@ round-trippable manner.
2341
2341
.. ipython :: python
2342
2342
2343
2343
df = pd.DataFrame({' foo' : [1 , 2 , 3 , 4 ],
2344
- ' bar' : [' a' , ' b' , ' c' , ' d' ],
2345
- ' baz' : pd.date_range(' 2018-01-01' , freq = ' d' , periods = 4 ),
2346
- ' qux' : pd.Categorical([' a' , ' b' , ' c' , ' c' ])
2347
- }, index = pd.Index(range (4 ), name = ' idx' ))
2344
+ ' bar' : [' a' , ' b' , ' c' , ' d' ],
2345
+ ' baz' : pd.date_range(' 2018-01-01' , freq = ' d' , periods = 4 ),
2346
+ ' qux' : pd.Categorical([' a' , ' b' , ' c' , ' c' ])
2347
+ }, index = pd.Index(range (4 ), name = ' idx' ))
2348
2348
df
2349
2349
df.dtypes
2350
2350
@@ -2864,6 +2864,19 @@ of sheet names can simply be passed to ``read_excel`` with no loss in performanc
2864
2864
data = pd.read_excel(' path_to_file.xls' , [' Sheet1' , ' Sheet2' ],
2865
2865
index_col = None , na_values = [' NA' ])
2866
2866
2867
+ ``ExcelFile `` can also be called with a ``xlrd.book.Book `` object
2868
+ as a parameter. This allows the user to control how the excel file is read.
2869
+ For example, sheets can be loaded on demand by calling ``xlrd.open_workbook() ``
2870
+ with ``on_demand=True ``.
2871
+
2872
+ .. code-block :: python
2873
+
2874
+ import xlrd
2875
+ xlrd_book = xlrd.open_workbook(' path_to_file.xls' , on_demand = True )
2876
+ with pd.ExcelFile(xlrd_book) as xls:
2877
+ df1 = pd.read_excel(xls, ' Sheet1' )
2878
+ df2 = pd.read_excel(xls, ' Sheet2' )
2879
+
2867
2880
.. _io.excel.specifying_sheets :
2868
2881
2869
2882
Specifying Sheets
0 commit comments