Skip to main content

reportlib

Flexible and powerful report library for Python or Python Notebooks with Pandas and Jinja2 support

Latest Release latest release
License license
Python Version python version
Wheel 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:

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)

Table of built distributions (wheels) for reportlib 3.4.0
File Interpreter ABI Platform
reportlib-3.4.0-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

3.4.0 This release

1 release file

3.3.0

1 release file

3.2.4

1 release file

3.2.3

1 release file

3.2.2

1 release file

3.2.1

1 release file

3.2.0

2 release files

3.1.3

1 release file

3.1.2

2 release files

3.1.1

1 release file

3.1.0

1 release file

3.0.0

1 release file

2.1.0

1 release file

2.0.5

1 release file

2.0.4

1 release file

2.0.3

1 release file

2.0.2

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page