Skip to content

BUG : pandas.DataFrame.to_excel function not working in pandas 1.3.1 #43068

Closed
@KuhakuPixel

Description

@KuhakuPixel
  • [✅ ] I have checked that this issue has not already been reported.

  • [ ✅] I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

# Your code here
writer = pd.ExcelWriter('existingFile.xlsx', mode='a')
df.to_excel(writer, sheet_name="existingSheet", startrow=writer.sheets["existingSheet"].max_row, index=False, header=False)

Problem description

It seems this function is broken in pandas 1.3.0, when trying to append to an existing sheet it will either raise an error, create a new one or replace it so it is impossible to append a data frame to an existing sheet. according to this document

if_sheet_exists{‘error’, ‘new’, ‘replace’}, default ‘error’
How to behave when trying to write to a sheet that already exists (append mode only).

error: raise a ValueError.

new: Create a new sheet, with a name determined by the engine.

replace: Delete the contents of the sheet before writing to it.

New in version 1.3.0

Expected Output

Able to append to an existing sheet without error

Output of pd.show_versions()

[paste the output of pd.show_versions() here leaving a blank line after the details tag]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions