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.2.tar.gz (54.0 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.2-py3-none-any.whl (55.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gp_treemap-0.6.2.tar.gz
  • Upload date:
  • Size: 54.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","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

Hashes for gp_treemap-0.6.2.tar.gz
Algorithm Hash digest
SHA256 afff263a821d0817e3ee6501a4590d226a2682c9999bf9e50f54dc8ab4e10290
MD5 87f8d7b0384cab99911ff9cb5263c4bd
BLAKE2b-256 b62f3a9abd55c5a3bb8e95e35cdedc21419c1e61c3b5eee55ea3ed9b2a494437

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gp_treemap-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 55.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","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

Hashes for gp_treemap-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b0ba1e12020c78b041c0712a3e2dfebee639b7f60a33c2821f3b7f2c69b56f1b
MD5 ad2fb2f0f77047da7c2e8e783dfa7460
BLAKE2b-256 dbc5ec0139b725fa7cc5f6ffc145c099d01c8f383cc768f5003d0a82aae7ce61

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