Render pandas or polars DataFrames and Series as HTML tables with flexibility for formatting and styling.
pip install "pandas-render[pandas]"
pip install "pandas-render[polars]"
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:
Name | Age | Hobbies |
---|---|---|
Alice | 25 years old | coding |
Bob | 30 years old | reading, hiking |
Exciting and more powerful features can be explored and learned in the Getting Started notebook.
List of all notebooks with examples:
Do you like this project? Fuel it with a ☕ coffee on Ko-fi. Every little bit helps and means a lot!
We encourage you to contribute to this project! Please check out the contributing guidelines about how to proceed.
This package is Open Source Software released under the BSD-3-Clause license.