Skip to main content

Notebooks

Use Notebooks to put queries, Python analysis, and explanations in one document. The notebook keeps cell source and saved outputs so you can revisit an analysis in Studio. Use a table for results that another notebook, dashboard, or flow needs to read.

Follow Analyze sample orders in a notebook to load a small CSV, run SQL and Python cells, and compare your results with known totals.

Create a notebook​

  1. Open Notebooks in the Studio sidebar and choose New notebook. Give it a name. Use folders to organize notebooks by topic or project.
  2. Add a Markdown cell for the purpose, expected inputs, and assumptions. Add a SQL cell to query a Gnok table, or a Python cell to use the notebook runtime.
  3. Confirm the workspace and any execution context shown in Studio. Start with a bounded query and review its output before relying on it downstream.
  4. Save to keep the current notebook. Use History to review or restore a saved version. Use Run all to check that the notebook runs from its first cell with a fresh kernel.
Cell typeWhat it does
SQLExecutes a Gnok query and shows the result. The latest SQL result is available to Python as _sqldf.
PythonRuns code and displays values, tables, and plots supported by the hosted environment.
MarkdownRenders prose, headings, lists, and code examples.
ParametersDefines typed inputs and defaults for repeatable runs.

Combine SQL and Python​

Put this query in a SQL cell:

SELECT 12 AS orders, 360.00 AS revenue;

Run the SQL cell, then add and run a Python cell below it:

orders = _sqldf.copy()
orders.assign(revenue_per_order=orders['revenue'] / orders['orders'])

The sample returns 30 in revenue_per_order. Save the SQL result to a named Python variable before running another SQL cell if you need both results. Keep setup cells above the cells that use them so a new kernel can reproduce the analysis.

Python can also call Gnok directly through the pre-installed gnok helper:

import gnok

gnok.sql('SELECT 1 AS connected').fetch_df()

The notebook forwards its authenticated Gnok identity. Source grants and data policies apply to the returned rows and fields. The Python notebook reference covers the supported data access, table writes, and model helpers.

Bring a Jupyter notebook into Studio​

Choose Import and open an .ipynb file as a new draft. Review the imported code, local file paths, package dependencies, and connection assumptions. Run the cells in Studio to regenerate outputs. Export downloads the notebook source as .ipynb for later use. Keep credentials in your authorized connection or environment rather than in cell source.

Find a lab and reuse its results​

If your workspace has notebooks in the library, open one and read its setup notes first. Start with its inputs and work through the cells in order. A dashboard can consume results you persist in a Gnok table, with the same table access rules as other dashboard datasets.

Continue with Run and schedule notebooks for fresh-kernel runs, parameter values, run outputs, and schedules.