reportlib
Flexible and powerful report library for Python or Python Notebooks with Pandas and Jinja2 support
| Latest Release |
|
| License |
|
| Python Version |
|
| Wheel |
|
What is it?
reportlib is a Python package providing fast and flexible utilities to decorate and render a report. Because it based on pandas's Styler, it is friendly with pandas DataFrame, so if you got your data, you can easily display and export it.
Main Features
Here are just a few of the things that reportlib does well:
- Powerful and flexible Styler based on pandas's Styler, friendly with pandas DataFrame, with more styling methods
- Friendly with Email: The HTML output use inline-css, you can send via email and that email also can be forwarded
- Friendly with Python Notebooks, so you can display Styler or Report in html
- Config parser: from string to other data types, for quickly get config from environment or other config files
- Customize everything with Jinja2 support: table head & foot (Styler), Report template, css
Where to get it
The source code is currently hosted on Teko's Gitlab at: https://git.teko.vn/data/libs/reportlib
Binary installers for the latest released version are available at the Python package index
pip install reportlib
Dependencies:
- css-html-js-minify: 2.5 or higher
- htmlmin: 0.1 or higher
- Jinja2: 2.10 or higher
- pandas: 0.24 or higher
- python-dateutil: 2.8 or higher
- PyYAML: 5.1 or higher
- premailer: 3.5 or higher
Installation from sources:
Clone the repository then execute following command in the reportlib directory (same one where you found this file after cloning the git repo)
python setup.py install
Alternatively, you can use pip if you want all the dependencies pulled in automatically (the -e option is for installing it in development mode):
pip install -e .
Basic usage
Project structure
root/ (or root/src/)
|-+-templates/
| |-styles.css
|-report.py
|-metadata.yml
...
Config report
export REPORT_DATE='2019-06-30'
Render report
"""report.py"""
import os
import pandas as pd
import numpy as np
from datetime import datetime
from dateutil.relativedelta import relativedelta
import reportlib
from reportlib import Report, ConfigParser, Styler
# Parse config from env
config = ConfigParser(config=os.environ)
report_date = config.date('REPORT_DATE', default='yesterday')
# Prepare data
df = pd.DataFrame(np.random.randn(8, 4), columns=['a', 'b', 'c', 'd'])
# Config report
reportlib.add_template_dir('templates')
Styler.set_option('precision', 2)
Styler.set_option('fillna', '-')
Styler.set_option('fillinf', '-')
Styler.set_option('fillzero', '-')
# Initial generator
report = Report(
styles='styles.css',
title='Report Demo',
context={
'report_date': report_date
},
)
# Styling data
style = (
Styler(df)
.add_class('bold highlight', subset=pd.IndexSlice[0:1, df.columns]) # Bold and Highlight some row by using class `highlight`
.add_class('text-right', columns=df.columns) # Align right columns
)
# Add tables
report.add_table(style)
# Run report
html_string = report.render()
# Or display it if you use a Python Notebook Interface like Jupyter
report.show()
Full Documentation
You can found full documentation in Wiki
Getting Help
For usage questions, the best place to go to is Full Documentation. Further, for general questions and discussions, you can create an issue or contact me via email at nhat.nv@teko.vn or via Teko's workplace
Contributing to reportlib
All contributions, bug reports, bug fixes, documentation improvements, enhancements and ideas are welcome.
Metadata
Release files for reportlib 3.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| reportlib-3.4.0-py3-none-any.whl | Python 3 | none | any | Details for reportlib-3.4.0-py3-none-any.whl |
Release files / reportlib-3.4.0-py3-none-any.whl
| Download URL | reportlib-3.4.0-py3-none-any.whl |
|---|---|
| Size | 15.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03d840d9011732715e1394a3904f9f145b39bff8b3b13cab718fef4d446b1d2d
|
|
BLAKE2b-256 checksum How to use checksums |
2d7881384d6b4154624c8fdbd46b0c737e9d8b46756e2734acaed1ea20c42ccc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.4
|
Security for reportlib 3.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.