panchawat.me
← back

Exploring Data with pandas (from a Jupyter Notebook)

python · data · jupyter

This post is what you'd get by exporting a Jupyter notebook to HTML and dropping it into the blog. The cells below mimic nbconvert output: an execution prompt, the source, and the rendered result — including a dataframe table.

In [1]:
import pandas as pd

df = pd.read_csv("sales.csv")
df.shape
Out[1]:
(1240, 4)
In [2]:
df.groupby("region")["revenue"].sum().sort_values(ascending=False)
Out[2]:
regionrevenueordersavg_order
APAC482,3001,204400.58
EMEA391,140998391.92
AMER356,8201,041342.77

The wrapper is plain HTML with a little CSS, so it themes with the rest of the site — light and dark both work. Because it's just markup, you can hand-tune any cell or splice in commentary between them, which is hard to do with a static screenshot.

Real nbconvert HTML uses class= and inline style="..." strings. In MDX those become className and style={{ ... }} — clean the export once and it renders natively.