-
Notifications
You must be signed in to change notification settings - Fork 2
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
Save to excel #262
Save to excel #262
Conversation
The doc issue comes from xclim and has been fixed in Ouranosinc/xclim@c846ca6. |
Does @sarahclaude or anyone else already have code to add some kind of table of contents to the excel ? I can write something simple if not. |
I had done this in previous code;
df1 could be provided by user in the argument. And I had this section in the loop that runs through the datasets;
|
Last commits added a simple toc. It can be localized (column names and long_names when available) with xclim's If the toc_tables = ... # Complex TOC generation...
# Write toc tables to the Content sheet
with pd.ExcelWriter(path, mode='a', if_sheet_exists='overlay') as writer:
startrow = 0
for toc_table in toc_tables:
toc_table.to_excel(writer, sheet_name='Content', startrow=startrow)
startrow += toc_table.length + 2
xs.io.save_to_table(ds, path, mode='a') # mode 'a' to append to file passed to pandas. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not in the new user request group, so I don't know if this fit for purpose. But, I played around withto_table
with a few of my data and it seems to work well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the flexibility of sheet/row/colums is great for future requests and works well!
Could accept strings in coords since all other similar arguments do
Pull Request Checklist:
number
) and pull request (:pull:number
) has been added.What kind of change does this PR introduce?
New
io.to_table
andio.save_to_table
for saving datasets to dataframes / csv / excel / etc.This adds support for multi-column and multi-sheet to
ds.to_dataframe()
.It also supports adding auxiliary coordinates as columns in the output table, beside the data variables. This is actually the most complex part of the code and it might not cover all cases 🙄...
I also sneaked in a little fix for
save_to_netcdf
, to allowcompute=False
. And I tookcoerce_attrs
out of the save function to reduce code duplication.Does this PR introduce a breaking change?
No.
Other information:
More testing and doc to come.