Skip to content

DOC: add type BinaryIO to path param #35505 #35568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 13, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion pandas/io/excel/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ class ExcelWriter(metaclass=abc.ABCMeta):

Parameters
----------
path : str
path : str or BinaryIO
Path to xls or xlsx or ods file.
engine : str (optional)
Engine to use for writing. If None, defaults to
Expand Down Expand Up @@ -596,6 +596,21 @@ class ExcelWriter(metaclass=abc.ABCMeta):

>>> with ExcelWriter('path_to_file.xlsx', mode='a') as writer:
... df.to_excel(writer, sheet_name='Sheet3')

You can store Excel file in RAM:

>>> import io
>>> buffer = io.BytesIO()
>>> with pd.ExcelWriter(buffer) as writer:
... df.to_excel(writer)

You can pack Excel file into zip archive:

>>> import zipfile
>>> with zipfile.ZipFile('path_to_file.zip', 'w') as zf:
... with zf.open('filename.xlsx', 'w') as buffer:
... with pd.ExcelWriter(buffer) as writer:
... df.to_excel(writer)
"""

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