Pandas Magic for Excel spreadsheets
Project description
Quick-start: https://0hughman0.github.io/xl_link/quickstart.html
Installation: ``pip install xl_link``
XLLink aims to provide a powerfull interface between Pandas DataFrames, and Excel spreadsheets.
XLLink tweaks the DataFrame.to_excel method to return its own XLMap object.
This XLMap stores all the information about the location of the written DataFrame within the spreadsheet.
By allowing you to use Pandas indexing methods, i.e. loc, iloc, at and iat. XLLink remains intuitive to use. But instead of returning a DataFrame, Series, or scalar, XLMap will instead return the XLRange, or XLCell corresponding to the location of the result within your spreadsheet.
Additionally XLMaps offer a wrapper around excel engines (currently supporting xlsxwriter and openpyxl) to make creating charts in excel far more intuitive. Providing a DataFrame.plot like interface for excel charts.
Chart demo
Here’s a teaser of what xl_link can do when combined with xlsx writer (for example):
>>> from xl_link import XLDataFrame >>> import numpy as np >>> f = XLDataFrame(data={'Y1': np.random.randn(30), 'Y2': np.random.randn(30)}) >>> xlmap = f.to_excel('Chart Demo.xlsx', sheet_name='scatter') >>> scatter_chart = xlmap.create_chart('scatter', x_axis_name='x', y_axis_name='y', title='Scatter Example') >>> xlmap.sheet.insert_chart('D1', scatter_chart) >>> xlmap.writer.save()
Which produces this chart:
.. image:: https://raw.githubusercontent.com/0Hughman0/xl_link/master/examples/ScatterExample.PNG)
Creating a complex chart like this:
is as easy as:
Setup >>> f = XLDataFrame(index=('Breakfast', 'Lunch', 'Dinner', 'Midnight Snack'), data={'Mon': (15, 20, 12, 3), 'Tues': (5, 16, 3, 0), 'Weds': (3, 22, 2, 8), 'Thur': (6, 7, 1, 9)}) Create chart with xl_link >>> xlmap = f.to_excel('Compare.xlsx', sheet_name="XLLinked", engine='openpyxl') >>> xl_linked_chart = xlmap.create_chart('bar', title="With xl_link", x_axis_name="Meal", y_axis_name="Calories", subtype='col') >>> xlmap.sheet.add_chart(xl_linked_chart, 'F1') >>> xlmap.writer.save()
This package uses the utility functions from XlsxWriter under the BSD license found here: https://github.com/jmcnamara/XlsxWriter
Copyright (c) 2016 0Hughman0
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file xl_link-0.131.tar.gz
.
File metadata
- Download URL: xl_link-0.131.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa0bc8cf62912efa0256fdabfc34400936387e1013c4963c94bd52a4be2e2a94 |
|
MD5 | c6e8caca17f8da2b3ff27ec42d2b8793 |
|
BLAKE2b-256 | 3688ae082b11a3d6ca5c530ba57fc68f75337c7614ca954d238b8abd2a623c76 |
File details
Details for the file xl_link-0.131-py3-none-any.whl
.
File metadata
- Download URL: xl_link-0.131-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b6002ab5b1409aa491fafbe84ee092529634285ed9cb17cf35208619a262a60 |
|
MD5 | 9c2caa792d8ee1bc741c7c641a11dee0 |
|
BLAKE2b-256 | e88ead0ed3c128184690bfce9dce52622d0f6e61e1adb460ca9b7dd58f50b178 |