Comment From: filmor
IMHO this should be the default behaviour to be consistent with to_hdf
.
Comment From: jreback
@jtratner this is like an append (to a single sheet)?
Comment From: jtratner
First, this is fundamentally different than to_hdf
, because for Excel, you'd probably be more likely to put them on separate sheets. Second, reading and writing is not supported by some of the Excel writers out there (for example, PyExcelerate gets fast speeds and low memory footprint by generating the file using jinja templating)...I think the only one you could use for this would be openpyxl
, but we switched to using xlrd
to read instead. And I'm pretty sure that openpyxl
would have to read in the entire file before it could alter it. One simple thing it would be reasonable to support would be to add a keyword argument specifically for engines that can read and write to tell them where to start adding the DataFrame. That way, you could say "Start in D100" and not overwrite the rest. (this may also already exist) - this could be useful if you want to add a DataFrame into a pre-existing excel file, etc.
That said, it's not clear to me what "append" means here, but I see a few options for how it would work: 1. Put the DataFrame next to the previous: so, for example if you had a DataFrame that was 100 columns, you'd start the next one on column 101. I guess if you do this, then you just ignore the other index and just line up the rows? 2. Concat the dataframes under the hood, then write. 3. Merge the dataframes under the hood, then write. [possibly with ignore index] 4. Have ExcelWriter keep track of the last set of columns it saw. Then reorder the columns such that they line up with the previous DataFrame and add extra columns at the end. Then start the Excel formatter just after the last row appended, have it go through everything, update the ExcelWriter's internal column store for the sheet, and then add the columns to the header row.
Given that you can do 1-4 in pandas itself, I don't really see why it makes sense to have the ExcelWriter try to do a poor job guessing defaults behind the scenes.
Both (1) and (4) can be implemented by telling the ExcelFormatter to start at a different location.
Comment From: wesm
Closing as won't fix