Notebooks Module

The Notebook feature provides an interactive Python environment embedded within each report. Use it to explore parameters, inspect query results, visualize data, and push outputs back into your final report—no local Python setup required.

Accessing the Notebook

  1. Open your report and click the Notebook tab.
  2. You’ll see a toolbar at the top and a series of code cells below.

Working with Cells

Notebooks consist of cells (code + output blocks):

  • Add a cell: Click the ➕ icon between cells to insert a new blank cell.
  • Delete a cell: Click the 🗑️ icon on a cell and confirm to remove it.
  • Reorder: Use the ↑/↓ arrows to move a cell up or down.

Running Code

  • Run cell: Click ▶️ on an individual cell to execute only that cell.
  • Run All: Click Run All in the toolbar to execute every cell in order and automatically save outputs.
  • Execution count: Each run increments the counter so you can track execution order.

Preloaded Data

On load, the Notebook initializes a Pyodide environment and injects data from your report:

  • ParamsObject: Access and pretty‑print your report’s parameters:

    ParamsObject Example

    If You edit parameters in the Parameters tab, click on Run Queries to see changes reflected in both params and dataset content.

  • DataFrameContainer: Wraps your query results as pandas DataFrames, complete with row/column counts:

    DataFrameContainer Example

These helpers render as HTML tables and images directly in the notebook.

Inspecting Query Results

Your report’s queries run before the notebook loads and are passed in via the datasets variable. Example:

DataFrameContainer Example

Use print_df to display a DataFrame in the notebook. You can also use df.head() to show the first few rows of any DataFrame.

Adding Outputs to Your Report

Toggle Add to Report Builder on any cell to include that cell’s final output (HTML table or image) in your report when saving. This lets you mix narrative text with live data insights.

Add to Report Example

Under the Hood

  • Available functions:
    • prind_df: Will output the pandas dataframe in a html table.
    • run_query(query, db_connection_name): Will run a query and return the results as a pandas dataframe.
  • Available Python Packages: Pyodide Comes by default with a set of packages, including:

    • pandas

    • numpy

    • matplotlib

    • scikit-learn

    • statsmodels

    • plotly

    • Check all available packages in the Pyodide documentation.

  • Some Packeges (like seasborn) are not available by default. You can install them using micropip in your notebook. For example, to install seaborn, run:
import micropip
await micropip.install(['seaborn'])

Example Code Snippet

Pandas Stats

Example Pandas Stats

Example Plot With Matplotlib and Seaborn

Example Plot

Best Practices

  • Focus: Keep each cell to a single purpose—data inspection, plotting, or parameter testing.
  • Re‑run Queries: After updating parameters in the Parameters tab, click Run Queries to refresh data.
  • Visualize: Use matplotlib to chart results; plots render inline thanks to a custom plt.show() hook.

Start experimenting with live Python in your reports today—your data, your code, your insights, all in one place!