Skip to content

Latest commit

 

History

History
75 lines (47 loc) · 2.33 KB

File metadata and controls

75 lines (47 loc) · 2.33 KB

pandas-render

pandas-render

Render pandas or polars DataFrames and Series as HTML tables with flexibility for formatting and styling.

GitHub Repo stars Ko-fi GitHub License

Installation

pip install pandas-render[pandas]
pip install pandas-render[polars]

Usage

This is a simple example that demonstrates the basic functionality. The column names are used to match individual Jinja2 templates. And {{ content }} is the placeholder for the content of the original cell.

from pandas_render import pandas as pd

df = pd.DataFrame(
    [
        dict(name="Alice", age=25, hobbies=["coding"]),
        dict(name="Bob", age=30, hobbies=["reading", "hiking"]),
    ]
)

df.render(
    templates=dict(
        name="<strong>{{ content }}</strong>",
        age="{{ content }} years old",
        hobbies="<em>{{ content|join(', ') }}</em>",
    ),
    table_column_names=["Name", "Age", "Hobbies"],
)

The result is a rendered dataframe:

NameAgeHobbies
Alice25 years oldcoding
Bob30 years oldreading, hiking

Examples

Exciting and more powerful features can be explored and learned in the Getting Started notebook.

List of all notebooks with examples:

Contributing

We encourage you to contribute to this project! Please check out the contributing guidelines about how to proceed.

License

This package is Open Source Software released under the BSD-3-Clause license.