perspective-python 5.6.0

Interactive data grid, pivot table and charts for large, real-time and streaming datasets, with a Jupyter widget and WebSocket server.
Documentation

perspective-python

PyPI

Perspective is an open-source data grid, pivot table and charting component for large, real-time and streaming datasets.

perspective-python is the Python distribution of Perspective:

  • A streaming query engine — Table and View — with incremental pivots, aggregates, filters, expressions and joins, reading and writing Apache Arrow, CSV, JSON, pandas, polars and pyarrow. Tables can be memory-mapped from disk with page_to_disk=True to exceed available memory.
  • PerspectiveWidget, an interactive data grid, pivot table and charting widget for JupyterLab, Jupyter Notebook, VS Code notebooks, Google Colab and marimo, built on anywidget.
  • WebSocket handlers for Tornado, Starlette (FastAPI) and aiohttp, which serve real-time dashboards to <perspective-viewer> in the browser.
  • Virtual servers which run the same UI directly against DuckDB, ClickHouse, PostgreSQL and Polars, with no data copy.

Installation

pip install perspective-python

For notebooks, install the jupyter extra:

pip install "perspective-python[jupyter]"

An interactive pivot table in Jupyter

import pandas as pd
from perspective.widget import PerspectiveWidget

df = pd.read_csv("superstore.csv")
PerspectiveWidget(df, plugin="Y Bar", group_by=["Region"], columns=["Sales"])

A streaming Table

import perspective

server = perspective.Server()
client = server.new_local_client()
table = client.table({"symbol": "string", "price": "float"}, name="prices")
table.update([{"symbol": "AAPL", "price": 189.5}])

A real-time dashboard server

import tornado.ioloop
import tornado.web
from perspective.handlers.tornado import PerspectiveTornadoHandler

app = tornado.web.Application([
    (r"/websocket", PerspectiveTornadoHandler, {"perspective_server": server}),
])

app.listen(8888)
tornado.ioloop.IOLoop.current().start()

Any number of browser clients can then open the prices table over WebSocket and receive every update() as it happens.

Documentation