Skip to content

Commit e67220d

Browse files
authored
DOC: add type BinaryIO to path param #35505 (#35568)
1 parent 88bc2e4 commit e67220d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

pandas/io/excel/_base.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ class ExcelWriter(metaclass=abc.ABCMeta):
551551
552552
Parameters
553553
----------
554-
path : str
554+
path : str or typing.BinaryIO
555555
Path to xls or xlsx or ods file.
556556
engine : str (optional)
557557
Engine to use for writing. If None, defaults to
@@ -606,6 +606,21 @@ class ExcelWriter(metaclass=abc.ABCMeta):
606606
607607
>>> with ExcelWriter('path_to_file.xlsx', mode='a') as writer:
608608
... df.to_excel(writer, sheet_name='Sheet3')
609+
610+
You can store Excel file in RAM:
611+
612+
>>> import io
613+
>>> buffer = io.BytesIO()
614+
>>> with pd.ExcelWriter(buffer) as writer:
615+
... df.to_excel(writer)
616+
617+
You can pack Excel file into zip archive:
618+
619+
>>> import zipfile
620+
>>> with zipfile.ZipFile('path_to_file.zip', 'w') as zf:
621+
... with zf.open('filename.xlsx', 'w') as buffer:
622+
... with pd.ExcelWriter(buffer) as writer:
623+
... df.to_excel(writer)
609624
"""
610625

611626
# Defining an ExcelWriter implementation (see abstract methods for more...)

0 commit comments

Comments
 (0)