-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Enable ExcelWriter to construct in-memory sheets #10376
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
Conversation
96d6fe4
to
7197f8f
Compare
@@ -249,10 +249,9 @@ Optional Dependencies | |||
* `statsmodels <http://statsmodels.sourceforge.net/>`__ | |||
* Needed for parts of :mod:`pandas.stats` | |||
* `openpyxl <http://packages.python.org/openpyxl/>`__, `xlrd/xlwt <http://www.python-excel.org/>`__ | |||
* openpyxl version 1.6.1 or higher, but lower than 2.0.0 |
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.
did you mean to take this out?
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.
Yes - both 1.x and 2.x are clearly supported and tested in excel.py and test_excel.py. I suppose the person who added the OpenPyXL 2.x path forgot to change this.
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.
hmm, IIRC there were some issues with >=2.0.0 and < 2.0.3 something like that (e.g. some style sheet issues. But ok, past that now, so ok.
|
||
if sheet.nrows == 0: | ||
return DataFrame() | ||
|
||
if header is not None: |
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.
what about sheet.nrows==1
(and its the header)? do we construct an empty frame with the correct columns?
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.
Yes, I added a test for this case and it works correctly already.
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.
yep, saw that below. thanks.
@@ -2184,6 +2184,38 @@ argument to ``to_excel`` and to ``ExcelWriter``. The built-in engines are: | |||
|
|||
.. _io.clipboard: |
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.
move your doc to before this refernce (for the next section)
38b74a9
to
465ceb0
Compare
@jreback The vbench for openpyxl is very slow ~ around 300s on my computer. This is around 10x slower than the next slowest test (sql). Should I reduce the df size for this test? |
yes, a vbench should be < 1s if at all possible, so reduce the size on these. |
e64196c
to
07fd4d6
Compare
I think it is finished once green - I snuck in one more Excel-related issue (testing xlwt on Py34). Openpyxl is very slow compared to xlsxwriter (5x slower) |
ahh, the yes, ping when green. |
@jreback ready |
@@ -2182,6 +2184,40 @@ argument to ``to_excel`` and to ``ExcelWriter``. The built-in engines are: | |||
|
|||
df.to_excel('path_to_file.xlsx', sheet_name='Sheet1') | |||
|
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.
can you add a reference here (so we can link to it)
minor doc comment. ping after you have pushed for merging. |
@jreback Added those. |
Add support for StringIO/BytesIO to ExcelWriter Add vbench support for writing excel files Add support for serializing lists/dicts to strings Fix bug when reading blank excel sheets Added xlwt to Python 3.4 builds closes pandas-dev#8188 closes pandas-dev#7074 closes pandas-dev#6403 closes pandas-dev#7171 closes pandas-dev#6947
Rebased |
ENH: Enable ExcelWriter to construct in-memory sheets
@bashtage thanks for this! |
Add support for StringIO/BytesIO to ExcelWriter
Add vbench support for writing excel files
Add support for serializing lists/dicts to strings
Fix bug when reading blank excel sheets
closes #8188
closes #7074
closes #6403
closes #7171