The Problem
Data scientists often have to switch between notebooks, ad‑hoc scripts, and separate BI tools to explore a pandas DataFrame. The friction of copying data, manually building charts, and re‑running cells makes iterative analysis slow and error‑prone.
What This Does
pygwalker turns any pandas DataFrame into an interactive web UI built with React, Tailwind and Flask. The core Python package lives in the pygwalker/ folder (67 files) and provides the PygWalker class, data‑parser hierarchy (data_parsers/base.py, data_parsers/database_parser.py) and a thin Flask server (api/webserver.py). The bundled front‑end lives under app/ (50 files) and is compiled with Vite (app/vite.config.ts). Example notebooks in examples/ demonstrate the Jupyter integration (api/jupyter.py) and a Reflex demo (examples/reflex_demo/app/app.py).
How It Is Wired
Execution starts at the CLI entry point bin/pygwalker_command.py (main function, line 124). main parses sub‑commands and eventually calls PygWalker.__init__ (in pygwalker/api/pygwalker.py). This initializer selects a data parser via get_parser (in pygwalker/services/data_parsers.py) and builds a chart spec with _init_spec. The spec is handed to the Flask server (api/webserver.py) which serves app/index.html.
Key call chain (shortest path to external effect):
main → PygWalker.__init__– creates a parser.PygWalker.__init__ → get_parser → _get_data_parser– loads the appropriate parser (e.g.,PandasDataFrameDataParser).PygWalker._get_datas → get_datas_by_sql / get_datas_by_payload– pulls data from the supplied DataFrame or SQL payload.PygWalker._init_spec → _get_props → get_local_user_id → _read_and_create_file– writes a small config directory on disk (os.makedirs).
Network traffic occurs in pygwalker/services/cloud_service.py (_upload_file_to_s3, read_config_from_cloud) and in the Flask server when the UI requests chart assets. File I/O is limited to the config folder (via _read_and_create_file) and optional uploads to S3. Cryptographic work is confined to pygwalker/services/data_parsers.py (_get_pd_dataset_hash).
The hub module pygwalker/data_parsers/base.py is imported by 20 other modules, giving it the highest blast radius. Three circular import groups (api/pygwalker.py, services/data_parsers.py, __init__.py) increase maintenance risk: any change forces a careful refactor to break the cycle. Deeply nested functions (up to 7 levels) appear in services/cloud_service.py and several React components, making the control flow harder to follow.
How To Use It
# Clone the repo
git clone https://github.com/moses-y/pygwalker
cd pygwalker
# Install the Python package (editable mode recommended)
pip install -e .
# Build the front‑end (requires Node ≥ 16)
cd app
yarn install # reads app/package.json & yarn.lock
yarn build # produces static assets referenced by the Flask server
Configuration is stored under the user’s home directory (~/.pygwalker) by default; the path is created by _read_and_create_file. To launch the UI from a notebook:
import pandas as pd, pygwalker as gw
df = pd.read_csv("data.csv")
gw.PygWalker(df).display()
For the CLI demo:
python -m pygwalker.command --data data.csv # entry point: bin/pygwalker_command.py
(Exact CLI flags are defined in bin/pygwalker_command.py.)
Real‑World Use
A data‑science team can embed PygWalker(df) in a Jupyter notebook to let analysts drag‑and‑drop fields, generate Vega‑Lite specs, and export the resulting chart as JSON. The same UI can be served internally via Flask for non‑technical stakeholders, with optional S3 upload of the generated spec for downstream reporting pipelines.
Code Health & Issues
- HIGH – Pin third‑party GitHub Actions to a commit SHA (
.github/workflows/*). - HIGH – Commit a lockfile alongside
pyproject.toml(currently missing). - MEDIUM – Declare least‑privilege
permissionsforGITHUB_TOKEN(.github/workflows/auto-ci.yml). - MEDIUM – Enable Dependabot or Renovate for automatic dependency updates.
- MEDIUM – Add a dependency‑vulnerability scan step in CI (
dependency-review-actionorosv-scanner). - MEDIUM – Set
persist-credentials: falseon the checkout step (.github/workflows/auto-ci.yml). - LOW – Add
timeout-minutesto workflow jobs (.github/workflows/publish.yml). - LOW – Add repository convention files (
.editorconfig,.gitattributes, formatter config).
Additional static‑analysis findings (not repeated here) include broad exception handling, empty catch blocks, duplicated code blocks, file handles without context managers, and high branching density.
The Bottom Line
pygwalker delivers a functional bridge between pandas and an interactive React UI, with a clear separation of parser logic and front‑end assets. The codebase is usable but hampered by import cycles, deep nesting, and several maintainability hotspots. It is suitable for teams comfortable with Python + React stacks who need rapid exploratory visual analysis, provided they allocate effort to resolve the highlighted health issues.