Skip to main content

pandas-plots

a comprehensive python package for enhanced data visualization and analysis with pandas dataframes. provides a high-level api for creating beautiful tables, plots, venn diagrams, and utility functions with minimal code.

PyPI - Version GitHub last commit GitHub License Python Versions


📦 installation

install package using uv (recommended)

uv add -U pandas-plots

use in python source

from pandas_plots import tbl, pls, hlp, const

🚀 features

  • table utilities (tbl): style dataframes as HTML tables with heatmaps, totals, kpi indicators, and percentages; describe column distributions with a single call
  • plotting functions (pls): plotly-based box plots, histograms, stacked bars, sankey diagrams, upset plots, facet charts, and more
  • helper functions (hlp): configure rendering for markdown export, cascade duckdb filters with counts, notebook and file utilities
  • cli (cli): convert Jupyter notebooks to Markdown or HTML for publishing

📤 publishing

notebook setup

call hlp.setup_rendering() at the top of your notebook to configure alle rendering settings:

# src/my_notebook.ipynb

from pandas_plots import hlp

hlp.setup_rendering(
    static=True,           # True for static rendering, False for interactive
    apply_dark_theme=False
)

convert to markdown

# src/convert.ipynb

from pandas_plots.cli.converter import jupyter_to_md

jupyter_to_md(
    path="src/my_notebook.ipynb",
    output_dir="./docs",      # output folder (created if missing)
    no_input=True,            # strip input cells from output
    execute=True,             # re-execute notebook before converting
    theme="system",           # None | "light" | "dark" | "system"
    chrome_path="/Applications/Chromium.app/Contents/MacOS/Chromium"  #  path to `ungoogled-chromium` binary
)

convert to html

from pandas_plots.cli.converter import jupyter_to_html

jupyter_to_html(
    path="src/my_notebook.ipynb",
    output_dir="./docs",
    no_input=True,
    execute=False,
    use_base64=False,  # False = images in separate folder, True = inline base64
)

🔍 examples

styled table

tbl.pivot_df(
    df[["color", "payment", "fare"]],
    total_mode="sum",
    total_axis="xy",
    data_bar_axis=None,
    total_exclude=True,
    pct_axis="xy",
    precision=0,
    heatmap_axis="xy",
    kpi_mode="rag_abs",
    kpi_rag_list=[1000, 10000],
    swap=True,
    font_size_td=12,
    font_size_th=14,
)

pivot

table description

tbl.describe_df(
    df,
    caption="taxis",
    top_n_uniques=10,
    top_n_chars_in_columns=10,
    top_n_chars_in_index=15,
)

table


upset plot

pls.plot_upset(
    df_upset,
    include_false_subsets=False,
    orientation="horizontal",
)

upset


uml graph

metrics = pls.plot_uml_graph()

uml


set filter

filter = hlp.get_duckdb_filter_n(
    con,
    "from Tumor",
    FILTERS,
    # distinct_metric="z_pat_id",
)
counts: rows
---
n = 3_241_401                                     (100.0%) ██████████████████████████████
└ [2020-2023.07]:                   n = 2_633_644  (81.3%) ░░░░░░████████████████████████
└ [not z_is_dco]:                   n = 2_547_636  (78.6%) ░░░░░░░███████████████████████
└ [keine M1]:                       n = 2_305_215  (71.1%) ░░░░░░░░░█████████████████████
└ [keine Verstorbenen < 180 Tage]:  n = 2_132_064  (65.8%) ░░░░░░░░░░░███████████████████
└ [lympho- und mesoendokr. Tumore]:    n = 27_653   (0.9%) ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

sankey diagram

_ = pls.plot_sankey(width=1000)

sankey


box plot with violin overlay

_ = pls.plot_box(df['fare'], height=400, violin=true)

box


box plot with statistics

_ = pls.plot_boxes_large(df[["dropoff_borough","distance"]])

box

venn diagrams

# show venn diagram for 3 sets
set_a = {'ford','ferrari','mercedes', 'bmw'}
set_b = {'opel','bmw','bentley','audi'}
set_c = {'ferrari','bmw','chrysler','renault','peugeot','fiat'}

_df, _details = pls.plot_venn3(
    title="taxis",
    a_set=set_a,
    a_label="cars1",
    b_set=set_b,
    b_label="cars2",
    c_set=set_c,
    c_label="cars3",
    verbose=0,
    size=8,
)

venn



📚 api reference

table utilities (tbl)

function description
show_num_df() displays a table as styled version with additional information
describe_df() alternative version of pandas describe() function
descr_db() short description for a duckdb relation
pivot_df() gets a pivot table of a 3 column dataframe (or 2 columns if no weights are given)
print_summary() shows statistics for a pandas dataframe or series

plotting functions (pls)

function description
plot_box() auto annotated boxplot w/ violin option
plot_boxes() multiple boxplots (annotation is experimental)
plot_stacked_bars() shortcut to stacked bars
plot_bars() standardized bar plot for categorical column with confidence intervals
plot_histogram() histogram for one or more numerical columns
plot_joints() joint plot for exactly two numerical columns
plot_quadrants() quickly shows a 2x2 heatmap
plot_facet_stacked_bars() stacked bars for a facet value as subplots
plot_sankey() generates a sankey diagram
plot_pie() generates a pie chart
plot_box_large() for large datasets using seaborn
plot_boxes_large() for large datasets using seaborn
plot_histogram_large() for large datasets using seaborn
plot_upset() generates an upset plot based on upsetplot
plot_uml_graph() generates a uml graph based on mermaid for structured data
plot_venn2() displays a venn diagram for 2 sets
plot_venn3() displays a venn diagram for 3 sets

helper functions (hlp)

function description
to_series() converts a dataframe to a series
mean_confidence_interval() calculates mean and confidence interval for a series
wrap_text() formats strings or lists to a given width
replace_delimiter_outside_quotes() replaces delimiters only outside of quotes in csv imports
create_barcode_from_url() creates a barcode from a given url
add_datetime_col() adds a datetime column to a dataframe (chainable)
show_package_version() prints version of a list of packages
get_os() helps identify and ensure operating system at runtime
add_bitmask_label() adds a column that resolves a bitmask column into human-readable labels
find_cols() finds all columns in a list that contain any of the given stubs
add_measures_to_pyg_config() adds measures to a pygwalker config file
get_tum_details() prints details of a specific tumor (requires connection to clinical cancer data)
get_duckdb_filter_n() print rowcounts for cascading filters in duckdb with ansi bars
print_filter() prints filter as markdown sql codeblock
is_ipynb() detects if code is running in jupyter notebook
prepend_uv_header() prepends uv header to a .py script to make it executable for uv run command
create_py_script() creates a .py script from a .ipynb file
setup_rendering() triggers clean(er) rendering of plots and pandas tables to markdown
find_str_in_duckdb() finds a given string in all tables of a DuckDB database
export_plot_data() exports the dataframe used for a plot to ./data/.csv
retrieve_file_from_gist() downloads a file from a github gist to the current directory

🧩 prerequisites

  • python 3.10+: compatible with python versions 3.10 - 3.13
  • uv: uv is recommended for package management

⚠️ this package depends on numpy<2.0.0 since UpSetPlot is still tied to the previous versions

static image export (kaleido)

static rendering (setup_rendering(static=True), svg/png export) uses plotly + kaleido. since kaleido>=1, chromium is no longer bundled with the package - kaleido needs a separate chrome binary to render images.

setup_rendering() handles this automatically: the first time it's called in static mode, it checks whether chrome is available and, if not, downloads a private chrome-for-testing build (one-time, ~150 MB, cached inside the venv). all later renders in that environment reuse it - no manual steps needed.

if the automatic download fails (e.g. no outbound network access on a locked-down company machine), you have two options:

  • install google chrome normally - it's auto-detected from its default install location
  • set the BROWSER_PATH environment variable to point at an existing chrome/chromium (or chromium-based) executable

🤝 contributing

contributions are welcome! please feel free to submit a pull request. for major changes, please open an issue first to discuss what you would like to change.


📄 license

this project is licensed under the MIT license - see the license file for details.


🏷️ tags

#pandas #visualizations #statistics #data-science #data-analysis #python

Metadata

Release files for pandas-plots 2.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pandas-plots 2.1.9
File Size Uploaded Provenance
pandas_plots-2.1.9.tar.gz 86.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pandas-plots 2.1.9
File Interpreter ABI Platform
pandas_plots-2.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 201.8 kB

Release files / pandas_plots-2.1.9.tar.gz

Download URL pandas_plots-2.1.9.tar.gz
Size 86.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ea52520e262c6d60fbf15d4d334271e28847028401f653e01a291917f7d65162
BLAKE2b-256 checksum
How to use checksums
f08fe5dc3eecef406f5773a9ee9eee4cd2c9efb1e3d722bc511a182f4a873c11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pandas_plots-2.1.9-py3-none-any.whl

Download URL pandas_plots-2.1.9-py3-none-any.whl
Size 114.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c52f8e0aa4df05f42d4c666581b083c86619442d44d71dda132fd093beec9b0
BLAKE2b-256 checksum
How to use checksums
0a16bccd7d9ac856af691800c1e7d3a9b9f3272c4ddcfad23f955f52e47db418
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for pandas-plots 2.1.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.1.9 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page