Skip to main content

This is a tool to run notebooks with input values. When you write the notebook, these are defined in the first code cell - or a cell with a ‘parameters’ cell tag - with regular assignments like this:

stock = 'YHOO'
days_back = 600

Nbparameterise handles finding and extracting these parameters, and replacing them with input values. You can then run the notebook with the new values. This can be used for:

  • Batch processing: run the same code on a list of different inputs. See examples/batch.py.

  • Simple user interfaces: build an input form based on the parameters, and run the notebook when the user submits the form. See examples/webapp.py for an implementation of this with an HTML form.

Nbparameterise can identify and replace numbers, strings, booleans (True/False), lists and dicts - the types which can be represented in JSON (apart from None). It’s designed to change parameter values but keep their types, although this isn’t enforced.

Extra information about the parameters, such as names to display in a user interface, can be stored in notebook metadata.

Nbparameterise is written in Python 3, but it can handle notebooks that use Python 2.

Usage:

import nbclient
import nbformat
from nbparameterise import (
    extract_parameters, replace_definitions, parameter_values
)

with open("Stock display.ipynb") as f:
    nb = nbformat.read(f, as_version=4)

# Get a list of Parameter objects
orig_parameters = extract_parameters(nb)

# Update one or more parameters
params = parameter_values(orig_parameters, stock='GOOG')

# Make a notebook object with these definitions
new_nb = replace_definitions(nb, params)

# Execute the notebook with the new parameters
nbclient.execute(new_nb)

If you are interested in using your parameterized Jupyter notebooks through a command line interface, have a look at nbclick.

Changes

1.0

2026-09-02

  • Compatibility with recent Python versions, up to & including Python 3.14.

  • The deprecated execute and execute_resources parameters in replace_definitions() were removed. Use nbclient if you want to execute the notebook with modified parameters.

  • The deprecated comments parameter for replace_definitions() was removed. Comments in the parameter cell are now always preserved.

0.6.1

2024-05-15

  • nbparameterise no longer requires nbconvert, and loads it only if you pass the deprecated execute=True option.

0.6

2023-02-28

  • The parameters cell no longer needs to be the first code cell: if you add a cell tag ‘parameters’ to another cell, parameters will be extracted from and replaced in that cell. Capitalisation doesn’t matter. (PR #27).

  • Only the parameter values are replaced: other code in the parameter cell will now be preserved unchanged (PR #19). The comment= parameter now has no effect, and it may be removed in a future version.

  • The execute= parameter for replace_definitions() is now deprecated. Please use nbclient to execute your notebook after substituting parameters.

  • nbparameterise now requires Python 3.8 or above.

Metadata

Release files for nbparameterise 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nbparameterise 1.0.0
File Size Uploaded
nbparameterise-1.0.0.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nbparameterise 1.0.0
File Interpreter ABI Platform
nbparameterise-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.5 kB

Release files / nbparameterise-1.0.0.tar.gz

Download URL nbparameterise-1.0.0.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0cb314efc150810c3dc87c0bd5aae78f5d04ab76ce594189acc007fbdb608b2a
BLAKE2b-256 checksum
How to use checksums
3bfabebff72ad9182b1d2d87b0bed7c9ea03a930bde0cc712322954ab9cd34d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.33.1

Release files / nbparameterise-1.0.0-py3-none-any.whl

Download URL nbparameterise-1.0.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
679f7692adc2cc7da7d29c83eb107a8bbc98457ea54ad1ea940b2ec201041ac4
BLAKE2b-256 checksum
How to use checksums
8a59faa4f98dc763ac7fa35f94f44964d197b74fdebb7ce58931efc78b5f562b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.33.1

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.6.1

2 release files

0.6

2 release files

0.5

2 release files

0.4

2 release files

0.3

2 release files

0.2

2 release files

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page