Skip to main content

Get the spreadsheet representation of a pandas data frame.

Project description

SpreadPandas: data frame to spreadsheet mapping

Python 3.7+ Code style: black GitHub license PyPI version fury.io PyPi

What is it?

SpreadPandas is a Python package to get the projected dimensions of a pandas data frame if it were to be transposed to a spreadsheet.

By creating a SpreadsheetMap object, understand which cells of a spreadsheet the data frame would occupy, with detail for its header, index and body.

The goal is for this package to serve as a basis to perform more complex operations, like Excel customization or Google Sheet exporting, that require to establish a precise mapping between the data frame content and the target cells.

Quick Start

Installation

You can install EasyPred via pip

pip install spreadpandas

Alternatively, you can install EasyPred by cloning the project to your local directory

git clone https://github.com/FilippoPisello/SpreadPandas

And then run setup.py

python setup.py install

Usage

Take an example pandas data frame:

>>> import pandas as pd
>>> df = pd.DataFrame({"COL1" : [1, 2, 3], "COL2" : [4, 5, 6]})
>>> df
   COL1  COL2
0     1     4
1     2     5
2     3     6

Use SpreadMap to get its spreadsheet mapping. Suppose the index should not be brought over to the spreadsheet:

>>> from spreadpandas import SpreadMap
>>> spreadmap = SpreadMap(df, keep_index=False)
>>> spreadmap.header.cells
('A1', 'B1')
>>> spreadmap.body.cells
('A2', 'B2', 'A3', 'B3', 'A4', 'B4')
>>> spreadmap.index
None

If the index should be kept instead:

>>> spreadmap = SpreadMap(df, keep_index=True)
>>> spreadmap.header.cells
('B1', 'C1')
>>> spreadmap.body.cells
('B2', 'C2', 'B3', 'C3', 'B4', 'C4')
>>> spreadmap.index.cells
('A2', 'A3', 'A4')

The content can also be moved by skipping rows and/or columns:

>>> spreadmap = SpreadMap(df, keep_index=True, skip_rows=2, skip_columns=1)
>>> spreadmap.header.cells
('C3', 'D3')
>>> spreadmap.body.cells
('C4', 'D4', 'C5', 'D5', 'C6', 'D6')
>>> spreadmap.index.cells
('B4', 'B5', 'B6')

Dependencies

EasyPred depends only on pandas.

Documentation

For the moment, this is the only documentation available.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spreadpandas-0.0.2.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

spreadpandas-0.0.2-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file spreadpandas-0.0.2.tar.gz.

File metadata

  • Download URL: spreadpandas-0.0.2.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.1

File hashes

Hashes for spreadpandas-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2b78d049f11e46e4951562601231d63a05a0b1f8ecf0b71ebefcc4ae0d2707ea
MD5 f9193286e07c9d13a8d4e8cdc4ea5cdc
BLAKE2b-256 7d72652ad7199f706c0141d0a7cafd5fc4244154553569422b8c96a552f3890b

See more details on using hashes here.

File details

Details for the file spreadpandas-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for spreadpandas-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ae67ef262720ba9aa8f6375eaf0c7cb6b7e1ff9fbb1759ea35f2c87d18948b8b
MD5 a6ecad88c946b892b1595a18952893e2
BLAKE2b-256 2fdc63f07a02e9352cc08fd57d9a832879165064ffb24bcc5447c10734b45e2a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page