ENH: Writing a DataFrame to Excel with XlsxWriter
in constant_memory mode requires row-by-row writes
#34710
Labels
Enhancement
IO Excel
read_excel, to_excel
Needs Discussion
Requires discussion from core team before further action
Is your feature request related to a problem?
When writing large DataFrames to an Excel file using
XlsxWriter
, one can use theoptions={'constant_memory': True}
keyword arguments.However, per the documentation: once this mode is active, data should be written in sequential row order.
The way pandas works at the moment, is that cells are written per series first, so column-by-column. This effectively writes the DataFrame so that only the first column and last row are fully written (along with the column names, which are written as a single row).
Describe the solution you'd like
It would be great to add an axis-like argument in the
to_excel
method, controlling how the data is written to the file (by columns (series) or by rows).API breaking implications
There should be no breaking implications. This new argument can have a default value that matches the current implementation.
Describe alternatives you've considered
Monkeypatching the ExcelFormatter as such works fine:
Additional context
Reproducible minimal example:
The text was updated successfully, but these errors were encountered: