Coder Social home page Coder Social logo

wchan757 / nbparameterise Goto Github PK

View Code? Open in Web Editor NEW

This project forked from takluyver/nbparameterise

0.0 1.0 0.0 31 KB

Programmatically replace input values in a notebook before running it

License: MIT License

Python 85.42% Jupyter Notebook 14.58%

nbparameterise's Introduction

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/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.

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 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, and execute it.
new_nb = replace_definitions(nb, params)

nbparameterise's People

Contributors

takluyver avatar irekrybark avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.