Skip to main content

Re-run a notebook substituting input parameters in the first cell.

Project description

This is a tool to run notebooks with input values. When you write the notebook, these are defined in the first code cell, 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/
  • Simple user interfaces: build an input form based on the parameters, and run the notebook when the user submits the form. See examples/ for an implementation of this with an HTML form.

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.


import nbformat
from nbparameterise import (
    extract_parameters, replace_definitions, parameter_values

with open("Stock display.ipynb") as f:
    nb =, 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, and execute it.
new_nb = replace_definitions(nb, params)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for nbparameterise, version 0.3
Filename, size File type Python version Upload date Hashes
Filename, size nbparameterise-0.3-py3-none-any.whl (8.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size nbparameterise-0.3.tar.gz (8.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page