Report builder for Pandas DataFrame
Project description
Pandas Reporter
Pandas Reporter is a report builder for Pandas DataFrame. It generates HTML, JSON, text, or YAML report containing the data in the data frame.
Installation
pip3 install pandasreporter
Usage
Create pandasreporter object and run it:
from pandasreporter import PandasReporter
# Prepare your data frame
data = {
"Name": ["Barkley", "Pippen", "Robinson"],
"DOB": ["19630220", "19650925", "19650806"],
"City": ["Philadelphia", "Chicago", "San Antonio"],
}
data_frame = pd.DataFrame(data)
pandas_reporter = PandasReporter()
_opts = {
"title": "Pandas Report",
"generator": "Pandas Reporter",
"rows_styler": <rows_styler_function>,
"max_col_size": 80,
}
pandas_reporter.report(
data_frame,
"html", # other formatters: json, text, or yaml
_opts,
)
Configuration
These are the optional properties that you can use with pandasreporter.report.
Some example report files are available on examples folder.
| Opt | Type | Description | Example | Formatter |
|---|---|---|---|---|
max_col_size |
Number | Maximum value length | 80 |
All |
title |
String | HTML report title value | Pandas Report |
html |
generator |
String | HTML report generator meta | Pandas Reporter |
html |
rows_styler |
Function | Data row styler | html |
HTML Rows Styler
Rows styler can be used to apply style to each of the table rows in HTML report.
Here's an example rows styler function which checks a row's "Expiry Date" column value against current date and a threshold date, and add background-color style accordingly:
def rows_styler(row):
today = pd.Timestamp.today()
threshold_date = today + pd.DateOffset(days=self.expiry_threshold_in_days)
if row["Expiry Date"] <= today:
style = ["background-color: LightPink"] * len(row)
elif row["Expiry Date"] <= threshold_date:
style = ["background-color: LightYellow"] * len(row)
else:
style = ["background-color: LightGreen"] * len(row)
return style
Report Formats
HTML
Text
┌──────────┬──────────┬──────────────┐
│ Name │ DOB │ City │
├──────────┼──────────┼──────────────┤
│ Barkley │ 19630220 │ Philadelphia │
├──────────┼──────────┼──────────────┤
│ Pippen │ 19650925 │ Chicago │
├──────────┼──────────┼──────────────┤
│ Robinson │ 19650806 │ San Antonio │
└──────────┴──────────┴──────────────┘
JSON
[
{
"Name":"Barkley",
"DOB":"19630220",
"City":"Philadelphia"
},
{
"Name":"Pippen",
"DOB":"19650925",
"City":"Chicago"
},
{
"Name":"Robinson",
"DOB":"19650806",
"City":"San Antonio"
}
]
YAML
- City: Philadelphia
DOB: '19630220'
Name: Barkley
- City: Chicago
DOB: '19650925'
Name: Pippen
- City: San Antonio
DOB: '19650806'
Name: Robinson
Colophon
Build reports:
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pandasreporter-1.0.1.tar.gz.
File metadata
- Download URL: pandasreporter-1.0.1.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.12.13 Linux/6.17.0-1010-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd51a8b94ef48de250d4cc3e62c7fb75d4335f54ca4bf8b9df3dca5fd76f9877
|
|
| MD5 |
5e53947542c42b34f91935622208c47c
|
|
| BLAKE2b-256 |
46988a546f83ef022eb9c59a8e57921f3bdbe7f5f564e05ab3f860dec67e0269
|
File details
Details for the file pandasreporter-1.0.1-py3-none-any.whl.
File metadata
- Download URL: pandasreporter-1.0.1-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.12.13 Linux/6.17.0-1010-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d741c74e92739410de1319f95a7481a151acee3c5fbba111cba7b99b934f9c3a
|
|
| MD5 |
984a8f6422da70472146a1176db759b7
|
|
| BLAKE2b-256 |
8f63a780d5ec235db1ddb684670aa17f00566e6b664096b8585320be3b4b0602
|