Opening the Python Editor
Open the code editor sidebar and choose Python as the language (you can switch between Python and SQL). It’s a Monaco-based editor (the same engine behind VS Code), with:- Syntax highlighting and autocomplete (keywords, built-ins,
pandas/numpy/scikit-learn/scipyimport snippets, and your sheet’s actual column headers as suggestions) - Inline error markers pointing at the failing line
- A resizable console panel showing
print()output, tables, and errors - Dark mode toggle
- An AI prompt box inside the editor so you can ask the AI to write the code for you without leaving the editor
- A prompt “optimizer” that rewrites a rough request into a more precise technical instruction before generating code
Execution Engine
Python code runs via Pyodide (CPython compiled to WebAssembly) in a background Web Worker, so it doesn’t freeze the UI.Available libraries:
pandas (as pd), numpy (as np), scikit-learn (sklearn), scipy.Other libraries (e.g. matplotlib, seaborn) are not available — charts are created via the create_chart() bridge function instead. See Charts.Reading Your Sheet: q.cells()
q.cells() automatically loads the requested range from the active sheet into a pandas DataFrame, using the first row of the range as column headers.
Writing Back to the Sheet
Depending on what you’re doing, use the matching bridge function rather than one big generic “set everything” call:Valid apply_filter condition types
Valid apply_filter condition types
is_equal_to, is_not_equal_to, text_contains, greater_than, less_than, greater_than_or_equal, less_than_or_equal, is_empty, is_not_empty, text_starts_with, text_ends_with, values (for matching a list of values).Text Output
Useprint() for explanations, summaries, or “Key Insights” style analysis instead of set_data() — this shows up in the console/chat as text rather than writing a new table to the sheet.
Creating Charts with create_chart()
Use create_chart() to build a chart directly from your Python code and place it on the sheet — no matplotlib/seaborn needed (those libraries aren’t available).
chart_type accepts any of Tablix’s chart types — 'line', 'area', 'column', 'bar', 'pie', 'doughnut', 'scatter', 'radar', 'waterfall', 'funnel', 'combo', 'histogram', and more. See the full list at Charts → Chart Types.
Option 1 — Chart Existing Columns
Point it at columns already on your sheet and let it aggregate for you:Region, sums Sales per group, and charts the result — no need to pre-aggregate with pandas first.
Multiple value columns become multiple series:
Option 2 — Chart Data You’ve Already Computed
If you’ve already calculated the numbers yourself (e.g. withpandas.groupby, or values that don’t map to raw columns), pass them directly with labels and values:
values, with matching series_names:
Use either
label_col/value_cols or labels/values — don’t mix the two in one call. Placement on the sheet and chart colors are both handled automatically; you don’t need to set a position or pick colors yourself.
