Python Analysis Cells
A Python Analysis Cell is a chart card that runs a Python script against your live datasource data and renders the result as an interactive ApexCharts visual. Think Jupyter notebook — but embedded directly in your dashboard, connected to your real data, and decorated with AI-generated insights automatically.
Plan requirement: Python Analysis Cells are available on Enterprise plans.
How it works
- Add a new chart and set the type to Python.
- AI Insights fetches a DataFrame from your datasource using the standard query configuration.
- Your script receives the data as a
dfvariable (a pandas DataFrame). - Your script returns a
resultdict describing the chart to render. - AI Insights renders the result as an ApexCharts visual and runs the AI narrative automatically.
All Python execution happens in the browser via Pyodide (Python compiled to WebAssembly). No server-side Python runtime is required.
Writing your first script
# df is pre-loaded from your datasource — no connection code needed.
import pandas as pd
monthly = df.groupby('Month')['Revenue'].sum().reset_index()
monthly['MA3'] = monthly['Revenue'].rolling(3).mean()
result = {
"chartType": "line",
"title": "Monthly Revenue with 3-Month Moving Average",
"labels": monthly['Month'].tolist(),
"values": monthly['Revenue'].tolist(),
"series": [
{"name": "Revenue", "data": monthly['Revenue'].tolist()},
{"name": "3-Month MA", "data": monthly['MA3'].fillna(0).tolist()}
]
}
Click ▶ Run to execute. The chart renders immediately.
The result object
| Key | Type | Required | Description |
|---|---|---|---|
chartType |
string | Yes | line, bar, column, area, pie, scatter |
title |
string | No | Chart title |
labels |
list | Yes | X-axis categories or pie slice labels |
values |
list | Yes | Primary numeric series |
series |
list of dicts | No | Multi-series — each dict has name and data |
Available libraries
| Library | Use case |
|---|---|
| pandas | DataFrames, groupby, rolling windows |
| numpy | Array math, statistics |
| scikit-learn | Regression, clustering, anomaly detection |
| scipy | Statistical tests, signal processing |
| statsmodels | ARIMA, OLS, exponential smoothing |
Limitations
| Limit | Value |
|---|---|
| Max input rows | 10 000 |
| Script timeout | 30 seconds |
| Network access | Blocked (browser sandbox) |
| Pyodide first-load | ~6 MB (cached permanently after first use) |