Skip to content

Change ExcelWriter modes to {"w","a"} #358

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 3 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion pandas-stubs/io/excel/_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class ExcelWriter:
engine: Literal["auto", "openpyxl", "pyxlsb", "odf"] | None = ...,
date_format: str | None = ...,
datetime_format: str | None = ...,
mode: Literal["w", "writer"] = ...,
mode: Literal["w", "a"] = ...,
storage_options: StorageOptions = ...,
if_sheet_exists: Literal["error", "new", "replace", "overlay"] | None = ...,
engine_kwargs: dict[str, Any] | None = ...,
Expand Down
8 changes: 8 additions & 0 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,14 @@ def test_excel_writer():
check(assert_type(ef.close(), None), type(None))


def test_excel_writer_append_mode():
with ensure_clean(".xlsx") as path:
with pd.ExcelWriter(path, mode="w") as ew:
DF.to_excel(ew, sheet_name="A")
with pd.ExcelWriter(path, mode="a") as ew:
pass


def test_to_string():
check(assert_type(DF.to_string(), str), str)
with ensure_clean() as path:
Expand Down