execute-python-analysis
Run Python code in an isolated subprocess for statistical/ML/visualization work beyond what SQL can express
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Run Python code in an isolated subprocess for statistical/ML/visualization work beyond what SQL can express
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
On-demand time-series forecasting. CAPTURE params from project context, call run_forecast, present deterministic engine results.
Use when helping initialize, configure, or prepare a Seeknal project like a coding agent
Translate business questions into metrics, SQL evidence, and actionable recommendations
Run multi-step SQL plus Python/statistics/ML analysis while keeping tools thin and evidence grounded
Answer business questions from read-only connected databases using deterministic schema discovery and SQL evidence
End-to-end workflow for adding a new pipeline node to a seeknal project — scaffold, validate, apply, and (optionally) run via the 5 thin pipeline-build tools
SOC 職業分類に基づく
| name | execute-python-analysis |
| description | Run Python code in an isolated subprocess for statistical/ML/visualization work beyond what SQL can express |
| tags | ["analysis","python","sandbox","pandas","matplotlib"] |
| version | 1.0.0 |
Use this workflow when the analysis requires Python capabilities that SQL
cannot express — statistical tests, visualization, machine learning, custom
algorithms, or complex pandas transformations. For simple data queries,
prefer execute_sql instead.
execute_python — runs code in an isolated subprocess sandboxUse execute_python for:
scipy.stats.ttest_ind, chi-square, ANOVA)matplotlibscikit-learnDO NOT use execute_python for:
execute_sqlexecute_sqlquery_metricconn.sql('SELECT * FROM ...') inside the codeEach execute_python call runs in a FRESH isolated subprocess. This has
implications you MUST account for:
conn object is ALREADY connected to your projectCRITICAL — do NOT create your own DuckDB connection. The sandbox
pre-loads a conn object (a SafeConnection wrapper around the real
project DuckDB) with EVERY project table/view already registered. It is
ready to use on the first line.
❌ WRONG — creates a new empty DB, loses all project data:
import duckdb
conn = duckdb.connect(':memory:') # shadows the sandbox conn
df = conn.execute("SELECT * FROM transform_daily_revenue").df()
# → CatalogException: Table with name transform_daily_revenue does not exist!
✅ RIGHT — use the pre-loaded conn directly, no imports:
df = conn.sql("SELECT * FROM transform_daily_revenue").df()
df.head(10)
The pre-loaded conn has:
source_customers, transform_daily_revenue,
feature_group_customer_features, etc.)target/intermediate/ mountedDo NOT import duckdb — the sandbox does not expect you to instantiate one.
If you're unsure what tables exist, run SHOW TABLES:
tables = conn.sql("SHOW TABLES").df()
print(tables)
No persistence between calls. Variables from a previous call do NOT exist in the next call. Re-query data at the start of every call:
df = conn.sql("SELECT * FROM customers").df()
Limited package set. These names may be pre-imported when installed in the current Seeknal environment:
conn — pre-loaded DuckDB SafeConnection (see above, do not re-create)pd — pandasnp — numpyplt — matplotlib.pyplot (Agg backend), or None if unavailablematplotlib — the full matplotlib package, or None if unavailablesklearn — scikit-learn (import submodules like sklearn.cluster)scipy — scipy (import submodules like scipy.stats)DO NOT import statsmodels, xgboost, lightgbm, tensorflow, torch,
plotly, or any other package — they are NOT installed. ModuleNotFoundError
means you chose the wrong library.
Last expression is returned (Jupyter style). Put a bare expression on the last line to capture its value:
df = conn.sql("SELECT * FROM orders").df()
df.describe() # ← captured and returned
DuckDB does NOT recognize # as a comment. If you put a Python-style #
comment inside a SQL string, the query fails with ParserException.
WRONG:
conn.sql("""
SELECT customer_id, total # get order totals
FROM orders
""").df()
RIGHT:
# Get order totals — comment is Python, outside the SQL string
conn.sql("""
SELECT customer_id, total
FROM orders
""").df()
Or use SQL -- comments inside the string:
conn.sql("""
SELECT customer_id, total -- this is a SQL comment
FROM orders
""").df()
Plots are captured automatically at the end of the call when matplotlib is
available. Check plt is not None before plotting. If it is None, do not
try to install/import matplotlib; provide a text/table answer or non-visual
statistics instead.
if plt is None:
print("Plotting unavailable in this environment; returning table summary.")
else:
plt.figure(figsize=(10, 6))
plt.hist(df['age'], bins=20)
plt.title('Age Distribution')
When plotting is available, just use plt:
plt.figure(figsize=(10, 6))
plt.hist(df['age'], bins=20)
plt.title('Age Distribution')
Do NOT call plt.show() — the sandbox captures all open figures to temp
PNG files and lists their paths in the return value. The agent can reference
these paths when building reports.
When execute_python returns an error, read the error type and retry:
ModuleNotFoundError or terminal_dependency_unavailable → the package
isn't available; do not retry the same import/charting path. Use another
available library or return a text/table answer.NameError → a variable from a previous call; re-query at the startParserException with # → Python comment inside a SQL string (see Phase 2)Execution timed out → simplify the query or break into smaller stepsThe tool surfaces a targeted hint for the first two cases automatically.
code: Python code to execute. Multi-line supported. Uses exec for
statements, eval for the last expression.