8000 DEP: Protect some ExcelWriter attributes by rhshadrach · Pull Request #45795 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

DEP: Protect some ExcelWriter attributes #45795

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 7 commits into from
Feb 6, 2022
Merged
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
Merge branch 'main' of https://github.com/pandas-dev/pandas into priv…
…atize_excel

� Conflicts:
�	pandas/io/excel/_odswriter.py
�	pandas/tests/io/excel/test_writers.py
  • Loading branch information
rhshadrach committed Feb 5, 2022
commit 0eaeb37f77fd20575041f36e0595d4d080908611
2 changes: 1 addition & 1 deletion pandas/io/excel/_odswriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ def _write_cells(
p = P(text=pvalue)
tc.addElement(p)

# add all rows to the sheet
if len(rows) > 0:
# add all rows to the sheet
for row_nr in range(max(rows.keys()) + 1):
wks.addElement(rows[row_nr])

Expand Down
17 changes: 17 additions & 0 deletions pandas/tests/io/excel/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,23 @@ def test_if_sheet_exists_raises(self, ext):
with pytest.raises(ValueError, match=re.escape(msg)):
ExcelWriter(f, if_sheet_exists="replace")

def test_excel_writer_empty_frame(self, engine, ext):
# GH#45793
with tm.ensure_clean(ext) as path:
with ExcelWriter(path, engine=engine) as writer:
DataFrame().to_excel(writer)
result = pd.read_excel(path)
expected = DataFrame()
tm.assert_frame_equal(result, expected)

def test_to_excel_empty_frame(self, engine, ext):
# GH#45793
with tm.ensure_clean(ext) as path:
DataFrame().to_excel(path, engine=engine)
result = pd.read_excel(path)
expected = DataFrame()
tm.assert_frame_equal(result, expected)

@pytest.mark.parametrize("attr", ["cur_sheet", "handles", "path"])
def test_deprecated_attr(self, engine, ext, attr):
# GH#45572
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0