PyGWalker
PyGWalker (from Kanaries) turns a pandas DataFrame into a Tableau-style exploration UI: drag fields onto shelves to build bar, line, scatter, and other charts, switch to a searchable data table, and save or export whatever you build – no chart code required.
Every chart is computed in your Python process and only the result is sent to the browser, so it costs about the same whether the data has 500 rows or 5 million.

The quick-start app: a pandas DataFrame in, a full drag-and-drop explorer out.
Installation
pip install 'shinywidgets[pygwalker]'Quick start
import plotly.express as px
import pygwalker
from shiny.express import ui
from shinywidgets import render_pygwalker
# Optional: stop PyGWalker's update checks (server and browser)
pygwalker.GlobalVarManager.set_privacy("offline")
ui.page_opts(fillable=True)
tips = px.data.tips()
@render_pygwalker
def explorer():
return tipsThat’s the whole app: a DataFrame in, a full drag-and-drop explorer out, filling its container.
set_privacy("offline") is optional. Without it, PyGWalker asks Kanaries’ servers for updates, from your server and from every visitor’s browser (which may then show an “update available” link). Call it before creating any PyGWalker widget; it also hides PyGWalker’s Kanaries cloud features.
Overview
A look at what you can build. Click any of them to open the app, with its code, in Shinylive.
Explorer features
Drag-and-drop chart building
Drag a field onto an axis shelf and PyGWalker infers a sensible mark, aggregates numeric measures (sum by default, changeable per field), and adds a legend for anything on Color. Dragging total_bill onto X, tip onto Y, and smoker onto Color produces:
import plotly.express as px
from shiny.express import ui
from shinywidgets import render_pygwalker
ui.page_opts(fillable=True)
ui.markdown(
"Drag **total_bill** onto *X-Axis*, **tip** onto *Y-Axis*, and **smoker** onto "
"*Color* -- PyGWalker aggregates, charts, and colors it, with no chart code."
)
tips = px.data.tips()
@render_pygwalker
def explorer():
return tips

The saved chart spec (Ctrl/Cmd+S, read back in Python) matches what’s on screen: the shelves hold columns: [total_bill], rows: [tip], color: [smoker].
Every explorer also has a Data tab next to Visualization – a searchable, paginated table over the same data, with a per-column histogram or category breakdown in the header. Rows are fetched from Python on demand, not shipped up front:

Any size dataset
The browser never holds your data – it sends SQL, and DuckDB runs it in your Python process, so only the query result crosses the wire. This explores 1,000,000 synthetic taxi-fare rows and builds an aggregated chart exactly as fast as the 244-row tips example above:
import numpy as np
import pandas as pd
from shiny.express import ui
from shinywidgets import render_pygwalker
ui.page_opts(fillable=True)
ui.markdown(
"1,000,000 synthetic rows. PyGWalker aggregates with DuckDB in the Python "
"process, so only the query *result* crosses the wire -- opening the explorer "
"and building a chart here cost the same bytes and time as "
"02_build_a_chart.py's 244 rows."
)
rng = np.random.default_rng(0)
n = 1_000_000
trips = pd.DataFrame(
{
"fare": rng.gamma(4, 3, n).round(2),
"distance_mi": rng.gamma(3, 1.5, n).round(2),
"borough": rng.choice(
["Manhattan", "Brooklyn", "Queens", "Bronx", "Staten Island"],
n,
p=[0.45, 0.25, 0.2, 0.07, 0.03],
),
"payment": rng.choice(["card", "cash"], n, p=[0.7, 0.3]),
}
)
@render_pygwalker
def explorer():
return trips
Opening the explorer and running the first chart query costs about the same regardless of row count: the initial render ships PyGWalker’s JavaScript bundle and schema once, and each aggregated chart query afterward sends back only a small query result, not the underlying rows.
PyGWalker’s own walk() is pinned to kernel_computation=True inside pygwalker.api.anywidget.walk() – passing kernel_computation=False yourself raises TypeError: ... got multiple values for keyword argument 'kernel_computation'. There’s no client-side mode through this renderer.
Reacting to interaction
There are no accessors on render_pygwalker, and nothing on the widget tracks the explorer’s live state, so reactive_read() has nothing to watch either. What is available: the widget accepts a .on_msg() handler, and every action the browser takes (building a chart, saving, exporting, switching tabs) arrives there as a pyg_request message. Two are useful to applications:
| Message action | Fires when | Payload |
|---|---|---|
update_spec |
User presses Ctrl/Cmd+S (or the save icon) | data["visSpec"]: the full chart spec (shelves, field roles, layout) |
export_dataframe_by_sql (or export_dataframe) |
User clicks the export icon | Nothing useful in the message itself – read pygwalker.GlobalVarManager.last_exported_dataframe immediately after |
This wires both up:
import json
import pandas as pd
import plotly.express as px
import pygwalker
from shiny import reactive
from shiny.express import render, ui
from shinywidgets import render_pygwalker
ui.page_opts(fillable=True)
tips = px.data.tips()
saved_spec = reactive.value(None)
exported = reactive.value(None)
with ui.layout_columns(col_widths=[8, 4]):
with ui.card(full_screen=True):
@render_pygwalker
def explorer():
return tips
with ui.card():
ui.card_header("What Python saw")
@reactive.effect
def _register_on_msg():
def on_msg(widget, content, buffers):
if content.get("type") != "pyg_request":
return
msg = content["msg"]
if msg["action"] == "update_spec": # Ctrl/Cmd+S
saved_spec.set(msg["data"]["visSpec"])
elif msg["action"].startswith("export_dataframe"): # export icon
exported.set(pygwalker.GlobalVarManager.last_exported_dataframe)
explorer.widget.on_msg(on_msg)
ui.markdown("Press **Ctrl/Cmd+S** in the explorer: its saved encodings land here.")
@render.code
def spec_summary():
spec = saved_spec.get()
if spec is None:
return "(not saved yet)"
encodings = spec[0]["encodings"]
used = {
shelf: [f["name"] for f in fields]
for shelf, fields in encodings.items()
if fields and shelf in ("columns", "rows", "color")
}
return json.dumps(used, indent=2)
ui.markdown("Click the export icon: the chart's computed rows land here.")
@render.data_frame
def exported_table():
df = exported.get()
if df is None:
return render.DataGrid(pd.DataFrame({"status": ["(not exported yet)"]}))
return render.DataGrid(df)Register the on_msg handler in a separate @reactive.effect, not inside explorer()’s own body.
Saving a chart (left) immediately shows its parsed shelves in Python (right); clicking export fills a real render.data_frame with the chart’s own computed rows – not the raw table, the aggregated rows behind the chart on screen:


The exported table’s total_bill_sum/tip_sum values match the two points plotted in the chart on the left, confirming export sends the chart’s computed data, not a dump of the input DataFrame.
Save and export are the only observable moments: the current selection, filter, or sort inside a chart isn’t readable from Python at all, and there’s nothing to react to continuously as a user drags fields around.
Updating in place
PyGWalker’s widget has no synced state trait, so there’s no in-place update path – every change means a re-render, which re-sends PyGWalker’s JavaScript bundle. Keep that in mind when a render function depends on something that changes often.
The one piece of explorer state you can carry across a re-render is a saved chart spec: capture it via update_spec (above), then pass it back as walk(df, spec=...) next time. PyGWalker’s own get_spec_json accepts the raw captured visSpec list as a JSON string directly:
import json
import plotly.express as px
from pygwalker.api.anywidget import walk
from shiny import reactive
from shiny.express import input, ui
from shinywidgets import render_pygwalker
ui.page_opts(fillable=True)
tips = px.data.tips()
saved_spec = reactive.value(None)
ui.input_select(
"day", "Day", choices=["All", *sorted(tips["day"].unique())], selected="All"
)
ui.markdown(
"Build a chart, then press **Ctrl/Cmd+S**. Switching the day filter re-renders "
"the explorer with the filtered data -- and replays the saved chart on it."
)
@render_pygwalker
def explorer():
day = input.day()
df = tips if day == "All" else tips[tips["day"] == day]
with reactive.isolate():
spec = saved_spec.get()
return walk(df, spec=json.dumps(spec) if spec else "")
@reactive.effect
def _capture_spec():
def on_msg(widget, content, buffers):
if content.get("type") != "pyg_request":
return
if content["msg"]["action"] == "update_spec":
saved_spec.set(content["msg"]["data"]["visSpec"])
explorer.widget.on_msg(on_msg)(reactive.isolate() keeps this render from re-running every time saved_spec itself changes – it should only react to day.) Build a chart, save it, then switch the day filter: the explorer re-renders against the filtered data, but the same chart (same shelves, same color) reopens on it, now showing smaller totals:


This is also the answer to “ship a pre-built exploration”: call walk(df, spec=...) with a spec captured once (e.g., written to a JSON file from a throwaway session) and every user opens on that chart, still free to change it from there.
Linking widgets
PyGWalker has no live accessors to wire into other widgets, so linking goes through the export round trip: this captures export_dataframe_by_sql, then feeds the exported rows into a render_plotly bar chart.
import pandas as pd
import plotly.express as px
import pygwalker
from shiny import reactive
from shiny.express import ui
from shinywidgets import render_plotly, render_pygwalker
ui.page_opts(fillable=True)
tips = px.data.tips()
exported = reactive.value(None)
with ui.layout_columns(col_widths=[7, 5]):
with ui.card(full_screen=True):
ui.card_header("Build a chart, then click the export icon")
@render_pygwalker
def explorer():
return tips
@reactive.effect
def _capture_export():
def on_msg(widget, content, buffers):
if content.get("type") != "pyg_request":
return
if content["msg"]["action"].startswith("export_dataframe"):
exported.set(pygwalker.GlobalVarManager.last_exported_dataframe)
explorer.widget.on_msg(on_msg)
with ui.card(full_screen=True):
ui.card_header("The same computed rows, as a plotly bar chart")
@render_plotly
def bar():
df = exported.get()
if df is None:
return px.bar(title="Export a chart to see it here")
num_col = next(c for c in df.columns if pd.api.types.is_numeric_dtype(df[c]))
cat_col = next(c for c in df.columns if c != num_col)
return px.bar(df, x=cat_col, y=num_col, title=f"{num_col} by {cat_col}")

Large data
Charts are aggregated in your Python process, so only results reach the browser (see Any size dataset and Large data & performance). Aggregations run in memory, so a very large one must fit in RAM.
Layout and sizing
In a filling layout (fillable=True, or a full_screen=True card), the explorer fills its container – PyGWalker’s own UI is tall and scrolls internally if the container is shorter. Outside a filling layout, the default height is a plain ipywidget default (400px), which is almost always too short; give it an explicit height (@render_pygwalker(height="420px") or output_widget("id", height="420px") in Core) sized to fit, and expect it to scroll:
import plotly.express as px
from shiny.express import ui
from shinywidgets import render_pygwalker
ui.page_opts(fillable=True)
tips = px.data.tips()
with ui.layout_columns(col_widths=[6, 6]):
with ui.card(full_screen=True):
ui.card_header("Fills the card (full_screen enabled)")
@render_pygwalker
def fill_explorer():
return tips
with ui.card():
ui.card_header('Explicit height="420px" (scrolls inside)')
@render_pygwalker(height="420px")
def fixed_explorer():
return tips
Gotchas
Security
PyGWalker draws charts by running SQL that the browser sends, in your Python process. That SQL is sandboxed: visitors can only query the data you gave the widget, not server files or other widgets’ data. But nothing limits how expensive a query is, and a slow one blocks every session while it runs, so PyGWalker is best suited to trusted or internal users.
Other gotchas
- “Open in desktop” and uploading charts to Kanaries with a visitor’s own token are disabled, and fail with a generic “Internal server error”.
- Export toasts point at a Jupyter-only variable:
walker.last_exported_dataframedoesn’t exist in a Shiny app. Readpygwalker.GlobalVarManager.last_exported_dataframeinstead. - A polars DataFrame needs a recent pygwalker, or
render_pygwalkerraises aTypeErrortelling you to passdf.to_pandas()instead. - Never use the top-level
pygwalker.walk()(orimport pygwalker as pyg; pyg.walk(df)) inside a Shiny render function: outside Jupyter it starts a blocking HTTP server instead of returning a widget. Usepygwalker.api.anywidget.walk()instead, which you should call directly when you needspec=,theme_key=, etc. - Reading
.widgetinside a renderer’s own render function returns the previous render’s widget, with no error. Registeron_msghandlers in a separate@reactive.effectinstead.
Learn more
- PyGWalker documentation
- PyGWalker on GitHub
help(shinywidgets.render_pygwalker)for the full parameter and security reference- Related guides: perspective, quak, mosaic
A filterable dashboard with export
A minimal filter + explorer starting point