Metadata-Version: 2.4
Name: pandasreporter
Version: 1.1.1
Summary: Report builder for Pandas DataFrame
License: Apache-2.0
License-File: LICENSE
Keywords: pandasreporter,...
Author: Cliffano Subagio
Author-email: cliffano@gmail.com
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: PyYAML (>=6.0.3,<6.1.0)
Requires-Dist: dominate (>=2.9.1,<2.10.0)
Requires-Dist: tabulate (>=0.10.0,<0.11.0)
Project-URL: Documentation, https://github.com/cliffano/pandas-reporter
Project-URL: Homepage, https://github.com/cliffano/pandas-reporter
Project-URL: Repository, https://github.com/cliffano/pandas-reporter
Description-Content-Type: text/markdown

<!-- BEGIN:AVATAR -->
![Avatar](avatar.jpg)
<!-- END:AVATAR -->

<!-- BEGIN:BADGES -->
[![Build Status](https://github.com/cliffano/pandas-reporter/workflows/CI/badge.svg)](https://github.com/cliffano/pandas-reporter/actions?query=workflow%3ACI)
[![Code Scanning Status](https://github.com/cliffano/pandas-reporter/workflows/CodeQL/badge.svg)](https://github.com/cliffano/pandas-reporter/actions?query=workflow%3ACodeQL)
[![Dependencies Status](https://img.shields.io/librariesio/release/pypi/pandasreporter)](https://libraries.io/github/cliffano/pandas-reporter)
[![Security Status](https://snyk.io/test/github/cliffano/pandas-reporter/badge.svg)](https://snyk.io/test/github/cliffano/pandas-reporter)
[![Published Version](https://img.shields.io/pypi/v/pandasreporter.svg)](https://pypi.python.org/pypi/pandasreporter)
<!-- END:BADGES -->

# 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

```shell
pip3 install pandasreporter
```

## Usage

Create pandasreporter object and run it:

```python
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](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:

```python
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

![Screenshot of report in HTML format](/screenshots/report-html.png "Report in HTML format")

### Text

```text
┌──────────┬──────────┬──────────────┐
│ Name     │      DOB │ City         │
├──────────┼──────────┼──────────────┤
│ Barkley  │ 19630220 │ Philadelphia │
├──────────┼──────────┼──────────────┤
│ Pippen   │ 19650925 │ Chicago      │
├──────────┼──────────┼──────────────┤
│ Robinson │ 19650806 │ San Antonio  │
└──────────┴──────────┴──────────────┘
```

### JSON

```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

<!-- BEGIN:DEVELOPERS_GUIDE -->
[Developer's Guide](https://cliffano.github.io/developers-guide-python.html)
<!-- END:DEVELOPERS_GUIDE -->

<!-- BEGIN:BUILD_REPORTS -->
Build reports:

* [Lint report](https://cliffano.github.io/pandas-reporter/lint/pylint/index.html)
* [Code complexity report](https://cliffano.github.io/pandas-reporter/complexity/radon/index.html)
* [Unit tests report](https://cliffano.github.io/pandas-reporter/test/pytest/index.html)
* [Test coverage report](https://cliffano.github.io/pandas-reporter/coverage/coverage/index.html)
* [Integration tests report](https://cliffano.github.io/pandas-reporter/test-integration/pytest/index.html)
* [API Documentation](https://cliffano.github.io/pandas-reporter/doc/sphinx/index.html)

<!-- END:BUILD_REPORTS -->

