Skip to content

DOC:add append example in to_excel documentation #27852

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
Aug 13, 2019
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
6 changes: 6 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2184,6 +2184,12 @@ def _repr_data_resource_(self):
automatically chosen depending on the file extension):

>>> df1.to_excel('output1.xlsx', engine='xlsxwriter') # doctest: +SKIP

To append data to an existing excel file:

>>> with pd.ExcelWriter('the_existing_file.xlsx', engine='openpyxl',
... mode='a') as writer:
... df.to_excel(writer)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example feels disconnected with the rest of the docstring.

I'd move it to line 2181, and say something like ExcelWriter can also be used to append to an existing Excel file. And then use the same file output.xlsx and append a sheet Sheet_name_3. I think that will be much clearer.

You also need the # doctest: +SKIP as in the other examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. You are right. That will be clearer. Will make the required change

"""

@Appender(_shared_docs["to_excel"] % dict(klass="object"))
Expand Down