xlFormulas
Helper class to write Excel-style formula strings to worksheets when saving from a Pandas dataframe.
Default initialization assumes the worksheet will be saved with an index and header row (the first real 'data' cell would be B2) but an index and header parameter are available to ensure alignment.
Pass in mathematical operators with strings, limited support currently for Excel built-in functions. If a value is not a column name in df.columns it is passed in as it is, whether that means it's an operator or builtin function.
The .formula() method returns a list of strings beginning with '=' and containing the row index for the Excel formula
Installation:
pip install xl-formulas
Basic usage:
import pandas as pd
from xlFormulas import ExcelFormulas
df = pd.read_excel('sample_data.xlsx')
# Pass in Pandas dataframe to intialize ExcelFormulas helper
ef = ExcelFormulas(df)
# Returns a column like "=B2+C2" in df['C']
df['C'] = ef.formula('A + B')
# Makes a "=(B2 + C2)/(C2 - D2)" column in df['D']
df['D'] = ef.formula(f'{ef.paren('A + B')} / {ef.paren('B - C')}'
# Use Excel built-in functions (Still pretty buggy)
# This would get a column of "=SUM(B2,C2,5)" in df['E']
df['E'] = ef.formula(ef.builtin('SUM', 'A', 'B', 'C'))
Release files for xl-formulas 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| xl-formulas-0.0.1.tar.gz | 2.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xl_formulas-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.6 kB
Release files / xl-formulas-0.0.1.tar.gz
| Download URL | xl-formulas-0.0.1.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9551c256bb6bf9c248d3efcc5d965f3b0c72f55de554c47b737463df33731a5
|
|
BLAKE2b-256 checksum How to use checksums |
98b55b4cc973a68918211f48ab2ee78a1881577261e7e240f2edaa762f5cd1a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.7.2
|
Release files / xl_formulas-0.0.1-py3-none-any.whl
| Download URL | xl_formulas-0.0.1-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a2aea6df1cd4415cfaaed839fede0332041bd79252eea366225f86f7895d953c
|
|
BLAKE2b-256 checksum How to use checksums |
ed04ed6f13033d5e4c766f895a27733d6c3bdeaa6be35db2faec81757c5e9725
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.7.2
|