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.shapeOut[1]:
(1240, 4)
In [2]:
df.groupby("region")["revenue"].sum().sort_values(ascending=False)Out[2]:
| region | revenue | orders | avg_order |
|---|---|---|---|
| APAC | 482,300 | 1,204 | 400.58 |
| EMEA | 391,140 | 998 | 391.92 |
| AMER | 356,820 | 1,041 | 342.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.