Skip to main content

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 leave color=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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gp_treemap-0.6.0.tar.gz (53.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gp_treemap-0.6.0-py3-none-any.whl (55.0 kB view details)

Uploaded Python 3

File details

Details for the file gp_treemap-0.6.0.tar.gz.

File metadata

  • Download URL: gp_treemap-0.6.0.tar.gz
  • Upload date:
  • Size: 53.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gp_treemap-0.6.0.tar.gz
Algorithm Hash digest
SHA256 0d5c0ab2f11bd5f2fc85a009255cae3a49b7607d50030f5bd8b9313459dfdfda
MD5 0ab7695188b8100a7c58ad421738a9b7
BLAKE2b-256 4666d2fcaa1935f130b1917aea3c4a0e920fcc3a27d095eaf077b39d5379ba1c

See more details on using hashes here.

File details

Details for the file gp_treemap-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: gp_treemap-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 55.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gp_treemap-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 baa09b798c663fc50be07bebe966e32ebe83ced919ef18f0dad87a274b4901e5
MD5 8cf58443e299227318265959a50ff0a2
BLAKE2b-256 81c8ebb4854ed24b0edbdd1bb25b72e790b720c9ccf2e799e089e5ca82a1e72c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page