|
| 1 | +Excelify |
| 2 | +======== |
| 3 | + |
| 4 | +Easily export ``pandas`` objects to Excel spreadsheets with IPython |
| 5 | +magic. |
| 6 | + |
| 7 | +|Build Status| |codecov| |
| 8 | + |
| 9 | +Example |
| 10 | +------- |
| 11 | + |
| 12 | +``%excel`` |
| 13 | +~~~~~~~~~~ |
| 14 | + |
| 15 | +.. code:: python |
| 16 | +
|
| 17 | + %load_ext excelify |
| 18 | +
|
| 19 | + data = [ |
| 20 | + {'name' : 'Greg', 'age' : 30}, |
| 21 | + {'name' : 'Alice', 'age' : 36} |
| 22 | + ] |
| 23 | + df = pd.DataFrame(data) |
| 24 | +
|
| 25 | + %excel df -f spreadsheet.xlsx -s sample_data |
| 26 | +
|
| 27 | +Magics |
| 28 | +------ |
| 29 | + |
| 30 | +``%excel`` |
| 31 | +~~~~~~~~~~ |
| 32 | + |
| 33 | +:: |
| 34 | + |
| 35 | + %excel [-f FILEPATH] [-s SHEETNAME] dataframe |
| 36 | + |
| 37 | + Saves a DataFrame or Series to Excel |
| 38 | + |
| 39 | + positional arguments: |
| 40 | + dataframe DataFrame or Series to Save |
| 41 | + |
| 42 | + optional arguments: |
| 43 | + -f FILEPATH, --filepath FILEPATH |
| 44 | + Filepath to Excel spreadsheet.Default: |
| 45 | + './{object}_{timestamp}.xlsx' |
| 46 | + -s SHEETNAME, --sheetname SHEETNAME |
| 47 | + Sheet name to output data.Default: |
| 48 | + {object}_{timestamp} |
| 49 | + |
| 50 | +``%excel_all`` |
| 51 | +~~~~~~~~~~~~~~ |
| 52 | + |
| 53 | +:: |
| 54 | + |
| 55 | + %excel_all [-f FILEPATH] [-n NOSORT] |
| 56 | + |
| 57 | + Saves all Series or DataFrame objects in the namespace to Excel. |
| 58 | + Use at your own peril. Will not allow more than 100 objects. |
| 59 | + |
| 60 | + optional arguments: |
| 61 | + -f FILEPATH, --filepath FILEPATH |
| 62 | + Filepath to excel spreadsheet.Default: |
| 63 | + './all_data_{timestamp}.xlsx' |
| 64 | + -n NOSORT, --nosort NOSORT |
| 65 | + Turns off alphabetical sorting of objects for export |
| 66 | + to sheets |
| 67 | + |
| 68 | +Dependencies |
| 69 | +------------ |
| 70 | + |
| 71 | +- IPython |
| 72 | +- Pandas |
| 73 | +- XlsxWriter ## Why? |
| 74 | + |
| 75 | +I had several Jupyter notebooks that were outputting crosstabs or |
| 76 | +summary statistics that would eventually end up in a Word doc. Depending |
| 77 | +on the size and complexity of the table, I would either copy/paste or |
| 78 | +export to Excel. Due to the inconsistency, this made managing all these |
| 79 | +tables a pain. I figured a tool like this would make it easier to |
| 80 | +collect everything in a notebook as part of an analysis into one excel |
| 81 | +file, deal with formatting in excel, and review and insert into a doc |
| 82 | +from there. |
| 83 | + |
| 84 | +.. |Build Status| image:: https://travis-ci.org/pmbaumgartner/excelify.svg?branch=master |
| 85 | + :target: https://travis-ci.org/pmbaumgartner/excelify |
| 86 | +.. |codecov| image:: https://codecov.io/gh/pmbaumgartner/excelify/branch/master/graph/badge.svg |
| 87 | + :target: https://codecov.io/gh/pmbaumgartner/excelify |
0 commit comments