Embed Observable cells hosted on observablehq.com into Jupyter notebooks.
Project description
observable_jupyter
Embed cells from Observable notebooks into Jupyter notebooks.
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file observable_jupyter-0.1.12.tar.gz
.
File metadata
- Download URL: observable_jupyter-0.1.12.tar.gz
- Upload date:
- Size: 218.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a184df95b74658e2558a97fd6a26f77638ee5626cd06c85589aef412cb7c6882 |
|
MD5 | 1eb76f02558f63c980a2f5c4979b21f1 |
|
BLAKE2b-256 | 348b8349a4345cf144862232af46b1c5bcab36ad7564d3214db9a91feeb09f8a |
File details
Details for the file observable_jupyter-0.1.12-py3-none-any.whl
.
File metadata
- Download URL: observable_jupyter-0.1.12-py3-none-any.whl
- Upload date:
- Size: 31.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3f24bdc6059a58637930f4d5058ea9db890d745165ab8b80977da41380900c5 |
|
MD5 | 4bde50a82163ec7fa17424e48150c582 |
|
BLAKE2b-256 | e6f98be6f20bef358903cd1a0a9f154db21642369bd18284e9002e14b3b33160 |