Skip to content

Commit aec9389

Browse files
author
Joeperdefloep
committed
resolved comments
1 parent 3c3eca4 commit aec9389

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

pandas/io/excel/_base.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -681,14 +681,14 @@ class ExcelWriter(metaclass=abc.ABCMeta):
681681
be parsed by ``fsspec``, e.g., starting "s3://", "gcs://".
682682
683683
.. versionadded:: 1.2.0
684-
if_sheet_exists : {'error', 'new', 'replace', 'write_to'}, default 'error'
684+
if_sheet_exists : {'error', 'new', 'replace', 'overwrite_cells'}, default 'error'
685685
How to behave when trying to write to a sheet that already
686686
exists (append mode only).
687687
688688
* error: raise a ValueError.
689689
* new: Create a new sheet, with a name determined by the engine.
690690
* replace: Delete the contents of the sheet before writing to it.
691-
* write_to: Write contents to the existing sheet.
691+
* overwrite_cells: Write contents to the existing sheet.
692692
693693
.. versionadded:: 1.3.0
694694
engine_kwargs : dict, optional
@@ -768,16 +768,16 @@ class ExcelWriter(metaclass=abc.ABCMeta):
768768
>>> df.to_excel(writer, sheet_name="Sheet1")
769769
770770
You can also write multiple DataFrames to a single sheet. Note that the
771-
`if_sheet_exists` parameter needs to be set to `write_to` if you are in
771+
`if_sheet_exists` parameter needs to be set to `overwrite_cells` if you are in
772772
append mode:
773773
774774
>>> with ExcelWriter("path_to_file.xlsx",
775775
... mode="a",
776776
... engine="openpyxl",
777-
... if_sheet_exists="write_to",
777+
... if_sheet_exists="overwrite_cells",
778778
... ) as writer:
779-
>>> df.to_excel(writer, sheet_name="Sheet1")
780-
>>> df.to_excel(writer, sheet_name="Sheet1", startcol=3)
779+
>>> df1.to_excel(writer, sheet_name="Sheet1")
780+
>>> df2.to_excel(writer, sheet_name="Sheet1", startcol=3)
781781
782782
You can store Excel file in RAM:
783783
@@ -964,10 +964,10 @@ def __init__(
964964

965965
self.mode = mode
966966

967-
if if_sheet_exists not in [None, "error", "new", "replace", "write_to"]:
967+
if if_sheet_exists not in [None, "error", "new", "replace", "overwrite_cells"]:
968968
raise ValueError(
969969
f"'{if_sheet_exists}' is not valid for if_sheet_exists. "
970-
"Valid options are 'error', 'new', 'replace' and 'write_to'."
970+
"Valid options are 'error', 'new', 'replace' and 'overwrite_cells'."
971971
)
972972
if if_sheet_exists and "r+" not in mode:
973973
raise ValueError("if_sheet_exists is only valid in append mode (mode='a')")

pandas/tests/io/excel/test_openpyxl.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def test_write_append_mode(ext, mode, expected):
139139
[
140140
("new", 2, ["apple", "banana"]),
141141
("replace", 1, ["pear"]),
142-
("write_to", 1, ["pear", "banana"]),
142+
("overwrite_cells", 1, ["pear", "banana"]),
143143
],
144144
)
145145
def test_if_sheet_exists_append_modes(ext, if_sheet_exists, num_sheets, expected):
@@ -171,7 +171,7 @@ def test_if_sheet_exists_append_modes(ext, if_sheet_exists, num_sheets, expected
171171
(
172172
"invalid",
173173
"'invalid' is not valid for if_sheet_exists. Valid options "
174-
"are 'error', 'new', 'replace' and 'write_to'.",
174+
"are 'error', 'new', 'replace' and 'overwrite_cells'.",
175175
),
176176
(
177177
"error",

0 commit comments

Comments
 (0)