Skip to content

Commit f5cc078

Browse files
Dunni3WillAyd
authored andcommitted
DOC: #25723 passing kwargs to excel document engine (#26465)
1 parent 6100652 commit f5cc078

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

doc/source/user_guide/io.rst

+17-4
Original file line numberDiff line numberDiff line change
@@ -2341,10 +2341,10 @@ round-trippable manner.
23412341
.. ipython:: python
23422342
23432343
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'))
23482348
df
23492349
df.dtypes
23502350
@@ -2864,6 +2864,19 @@ of sheet names can simply be passed to ``read_excel`` with no loss in performanc
28642864
data = pd.read_excel('path_to_file.xls', ['Sheet1', 'Sheet2'],
28652865
index_col=None, na_values=['NA'])
28662866
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+
28672880
.. _io.excel.specifying_sheets:
28682881

28692882
Specifying Sheets

0 commit comments

Comments
 (0)