Python wrapper around gp-treemap: pandas DataFrame → self-contained HTML treemap.
Project description
gp_treemap
Python wrapper around gp-treemap:
turn a pandas DataFrame into a self-contained, interactive treemap HTML
page. Mirrors the spirit of plotly.express.treemap for the
path/values/color arguments, but emits the HTML directly — no
Plotly Figure intermediate.
Install
pip install gp_treemap
The JS bundle and loader ship as package data, so the rendered HTML is fully offline: no CDN, no network fetch.
Usage
import pandas as pd
from gp_treemap import treemap
df = pd.DataFrame({
"continent": ["EU", "EU", "AS", "AS"],
"country": ["FR", "DE", "CN", "JP"],
"fuel": ["nuclear", "coal", "coal", "nuclear"],
"twh": [380, 280, 5400, 70],
})
fig = treemap(df, path=["continent", "country", "fuel"], values="twh",
color="fuel", title="2023 generation by fuel")
fig.write_html("out.html") # standalone file
fig.show() # open in browser
fig # in Jupyter, renders inline (iframe srcdoc)
Arguments
path: column names describing the hierarchy, outermost first.values: numeric column whose per-group sum drives cell size. Defaults to row-count.color: column name. Numeric → continuous palette; non-numeric → categorical hash. Pass"[Level 1]"(or leavecolor=None) to colour by the topmost visible ancestor — recomputed every time you zoom.theme,palette: gpdu themes / palettes ("tokyo-night","nord","viridis","turbo", …).
Development
This package wraps the JS bundle built from the root of the repo. After
running node tools/build.js at the repo root, refresh the bundled
artifacts:
bash python/scripts/refresh_bundle.sh
Then run the tests:
cd python
python -m venv .venv && .venv/bin/pip install -e . pytest pandas numpy
.venv/bin/pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gp_treemap-0.6.1.tar.gz.
File metadata
- Download URL: gp_treemap-0.6.1.tar.gz
- Upload date:
- Size: 53.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77a66f44e6ea8171d30c9d3d5bf308c5a75d1814263ff8ad8d35329723622895
|
|
| MD5 |
b2dc301cb095b2e34e14563b8ecf3079
|
|
| BLAKE2b-256 |
d7c4357e9976a7d092bb5d3e9421aa4c5a2c27f4e12c8fa5442052d889eef1b1
|
File details
Details for the file gp_treemap-0.6.1-py3-none-any.whl.
File metadata
- Download URL: gp_treemap-0.6.1-py3-none-any.whl
- Upload date:
- Size: 55.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0babf66f92a571a02a0073cbe05ca1f7e63ab678e81be3bb2c7f0c209a685e7
|
|
| MD5 |
f8076815e200c8935f5cd6ac4134999b
|
|
| BLAKE2b-256 |
c85be48259d3ff15a0306714854997464bf470ccfe68ab9b6d71740dd96b06e3
|