Skip to main content

observable-jupyter

Embed cells from Observable notebooks into Jupyter notebooks.

View demo notebook on Colab

This library provides a simple way to embed cells and pass custom inputs values to them from Python code. For more complicated data flow in Jupyter notebooks, see the related library observable-jupyter-widget which uses the Jupyter Widget system to pass data back and forth between Python and JavaScript.

Usage

To install the library, import the embed function, and embed the "graphic" cell from this Observable notebook:

!pip install observable_jupyter
from observable_jupyter import embed
embed('@mbostock/epicyclic-gearing', cells=['graphic'], inputs={'speed': 0.2})

The simplest way to use embed() is to render an entire Observable notebook:

embed('@d3/gallery')

You may want to swap in your own data into a D3 chart:

import this
text = ''.join(this.d.get(l, l) for l in this.s)
embed('@d3/word-cloud', cells=['chart'], inputs={'source': text})

With multiple cells, you can embed interactive charts!

embed(
    '@observablehq/visualize-a-data-frame-with-observable-in-jupyter,
    cells=['vegaPetalsWidget', 'viewof sepalLengthLimits', 'viewof sepalWidthLimits'],
)

Embedding specific cells with the cell keyword parameter of embed([]) causes only these cells to be shown, but every cell still runs.

This behavior is slightly different than the Observable embed default.

About this library

This library uses the APIs provided by Observable to embed notebooks hosted on Observable in Jupyter.

The library was developed at Observable but is now maintained by Thomas Ballinger. All code added before Sept 2021 is copyright Observable.

Development

See ARCHITECTURE.md for an overview.

Because Python library includes JavaScript, you'll need node as well as Python to contribute to it.

The two JavaScript files included in an installed package iframe_bundle.js and wrapper_bundle.js are not saved in this repo. They are generated by rollup, a JavaScript "bundler" that combines JavaScript source code from files in the js folder and dependencies listed in js/package.json.

Installing the Python package with or pip install -e . will automatically run the bundler and produce these files.

Metadata

Release files for observable-jupyter 0.1.14

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

Source distribution (sdist)

Source distribution for observable-jupyter 0.1.14
File Size Uploaded Provenance
observable_jupyter-0.1.14.tar.gz 34.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for observable-jupyter 0.1.14
File Interpreter ABI Platform
observable_jupyter-0.1.14-py3-none-any.whl Python 3 none any Details

Total release size: 65.6 kB

Release files / observable_jupyter-0.1.14.tar.gz

Download URL observable_jupyter-0.1.14.tar.gz
Size 34.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d7b358bcfd77c2c5667a8c20daa7431c9674c68fc04d9c239d2c2d00e319c225
BLAKE2b-256 checksum
How to use checksums
8cd725b4652151c89814f829647c0a4882f1b9096dc466280fb24cf2ed19300f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.3

Release files / observable_jupyter-0.1.14-py3-none-any.whl

Download URL observable_jupyter-0.1.14-py3-none-any.whl
Size 31.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8b3090855203b312c6cffab61a67630112f539a91c0df65c7950dea6b2e842c
BLAKE2b-256 checksum
How to use checksums
1472cce54a7ca253e3c7f143c5c4ba5760af21b0b7a13fb86a10c2a088819699
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.3

Security for observable-jupyter 0.1.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.14 This release

2 release files No provenance

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