Skip to main content

Getting started

1000 Words helps data scientists communicate their findings. The thousandwords Python package exposes a %%publish magic that turns any Jupyter cell into a shareable web-hosted Python script.

If you find yourself screenshotting plots and dataframes in Jupyter, you might want to give it a try.

When you run a cell tagged with %%publish, it gets decoupled from the rest of the notebook through a process of dependency serialization. Any variable required to run the cell gets serialized and uploaded to the web app. The code is then remotely executed and the output captured. The result is a web-hosted Python script that you can easily share.

Your audience can view your visuals and how they were produced. They're also able to rerun the code and to programmatically explore the cell's variables.

By default, publications are private and can only be viewed by the people you invite.

Installation

To install from PyPI:

pip install thousandwords

Usage

Import the publish module to register the %%publish magic command:

from thousandwords import publish

Create a shareable snippet of code from Jupyter or ipython with %%publish:

%%publish
# Your Python code goes here..

A more complete example

Start a new ipython session or create a new Jupyter notebook.

Paste the following snippet:

from thousandwords import publish
from sklearn import datasets
import matplotlib.pyplot as plt

# Loading iris public dataset
iris = datasets.load_iris(as_frame=True).data

Run:

%%publish
plt.scatter(iris['sepal length (cm)'], iris['sepal width (cm)'])

This creates a new shareable URL like so: https://1000words-hq.com/c/MRl2BeK9tRC.

The cell's code, data (i.e. the iris DataFrame) and outputs (the scatter plot image) are captured and kept in long-term storage.

A Python console lets anyone with the link programmatically explore the snippet. The code can be reran and forked. Reproducibility is guaranteed.

Demo