Skip to content

Excelfancy #2370

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 11 commits into from
Nov 29, 2012
Merged

Excelfancy #2370

merged 11 commits into from
Nov 29, 2012

Conversation

jassinm
Copy link

@jassinm jassinm commented Nov 27, 2012

adds to export dataframe for excel:
- multiindex (merge cells similar to htmlformatter)
- border
- bold header
- ability to add dataframe in same sheet (startrow, startcol)

http://cl.ly/image/2r102L0E1l23

solves Issue #2294

@wesm
Copy link
Member

wesm commented Nov 27, 2012

Oh that's very nice. Would you might sprinkling in some test cases?

@changhiskhan
Copy link
Contributor

+1

@jassinm
Copy link
Author

jassinm commented Nov 27, 2012

cool. sure I tried to add but ./test_fast.h

======================================================================
ERROR: Failure: ImportError (C extensions not built: if you installed already verify that you are not importing from the source directory)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/local/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/local/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/Users/locojay/Documents/Dev/github/pandas/pandas/__init__.py", line 16, in <module>
    raise ImportError('C extensions not built: if you installed already '
ImportError: C extensions not built: if you installed already verify that you are not importing from the source directory

----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (errors=1)

not sure if related to the osx build issue which was solved over weekend

@wesm
Copy link
Member

wesm commented Nov 27, 2012

try building the extensions in place : python setup.py build_ext --inplace

@wesm
Copy link
Member

wesm commented Nov 27, 2012

Shortcut for that is make tseries

@jassinm
Copy link
Author

jassinm commented Nov 27, 2012

thanks works wil add some tests

@jassinm
Copy link
Author

jassinm commented Nov 28, 2012

  • all frame test are green
  • excel export looks like html export when dealing with index_labels (not in same row as columns)
  • small fix to reader, functionality to deal with new index label style

What is missing is to add to the Reader the functionality to read multindex columns (pivot dumps....). Maybe a feature for the future

@wesm
Copy link
Member

wesm commented Nov 29, 2012

Great, thanks. I'll go ahead and merge this-- if you get a chance to write some docs, go for it in a new PR

@wesm
Copy link
Member

wesm commented Nov 29, 2012

There are test failures in this on my machine. I'll hack it to work-- just checking you ran all ~2600 tests from test_fast.sh? (or nosetests pandas)

@jassinm
Copy link
Author

jassinm commented Nov 29, 2012

was just running nosetests -s pandas.tests.test_frame apologies
I get 2 fails:
pandas.stats.tests.test_ols.TestOLS (not sure if related)
pandas.tests.test_panel.TestPanel:test_to_excel.

This one is due to the handling of the Excel Reader when dealing with index labels :

The new dump does it like the HTML dumper and offset by 1 row if an index has a label.
I assumed that if a row has no values in the columns its an indexname...
Any thoughts one what would be a good way to deal with this so one can handle parsing frames having no index label but an empty first value row? add an argument to the parser (has_indexname?), check type of column if first element is different must be an indexname

…ls not in the same row as columnnames

has_index_labels: boolean, default False
    True if the cols defined in index_col have an index name and are
    not in the header
@jassinm
Copy link
Author

jassinm commented Nov 29, 2012

  • added argument has_index_labels to the reader to handle index_labels not in the same row as the column header.
  • people using the parser don't need to add any argument if they have files dumped in the previous layout.
  • for the new layout (index labels offseted by one row) one needs to add has_index_labels=True
  • all but one tests passes when running nosetets pandas. This is unrelated has it occurs in master (fbd77d5) (pandas.stats.tests.test_ols.TestOLS:testWLS)

@ghost ghost assigned wesm Nov 29, 2012
@wesm
Copy link
Member

wesm commented Nov 29, 2012

Thanks a ton. You can get rid of that error by upgrading to the latest development version of statsmodels

@jassinm
Copy link
Author

jassinm commented Nov 29, 2012

great thanks all green now

wesm added a commit that referenced this pull request Nov 29, 2012
@wesm wesm merged commit 389da90 into pandas-dev:master Nov 29, 2012
@wesm
Copy link
Member

wesm commented Nov 29, 2012

If you get a chance to write some documentation (look in docs/source), that'd be great!

@ghost
Copy link

ghost commented Nov 29, 2012

@wesm, Looks like xlwt was introduced as a hard dependency, xlwt doesn't install on python3,
and the port to python3 xlwt3 is abandonware. release-blocker?

@changhiskhan
Copy link
Contributor

So there seems to be a bug in openpyxl 1.5.8 where the cell styles don't get read in correctly but they do get written correctly still.

@blounsbury-usbr
Copy link

Just wanted to say that although the original posters screenshot (though missing the right border of the last column header) looks alright, it shouldn't mean that everyone else be forced to use his style preference.

I would request that the default output be changed back the way it has been, and an additional to_excel parameter be added for those who wish to use this style preference. I don't want my output formatted this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants