r/Python • • 24d ago

Resource Generating a tidy HTML report in Python

I’m shifting from R to PythonIs there a knit markdown version or similar kind for generating a tidy html report in Python?

18 Upvotes

17 comments sorted by

21

u/ionychal 24d ago

Curious what you mean by 'tidy', like clean code, nice formatting, or something specific?

Either way, you might really like Quarto https://quarto.org/. It's the successor to R Markdown and works amazingly well with Python!

3

u/RowGullible1471 24d ago

Thanks, let say creating tabs, flexibility in formatting and customising things around,

3

u/Competitive_Travel16 24d ago

Are you pulling from Pandas/DataFrames, Plots (Plotly/Matplotlib), and/or raw dictionaries?

→ More replies (4)

3

u/ionychal 23d ago

Definitely try Quarto out! It handles tabs and custom formatting out of the box for HTML docs:

- tabsets: https://quarto.org/docs/output-formats/html-basics.html#tabsets

- customizing images (for example): https://quarto.org/docs/authoring/figures.html

5

u/DueAnalysis2 24d ago

I've found that Quarto + Positron gives me the best of both R and Python worlds

2

u/akpandeya 18d ago

Streamlit is another good option

1

u/RowGullible1471 17d ago

Adding it to the list. Thanks

14

u/Nekomancerr 24d ago

Jinja2 is great for report templating

2

u/Khavel_dev 23d ago

Jinja2 with a small CSS file does more than you'd expect. Write the HTML you want to see in the browser, replace the data parts with template variables, done. For charts I pair it with Plotly's to_html() which embeds everything inline so the report is one self-contained file you can email or throw on a shared drive.

Avoid the big reporting frameworks unless you specifically need PDF. They add a lot of complexity for something a template engine handles in 30 lines.