Skip to content

Jupyter Integration

Datapane has first-class Jupyter Notebook support. This includes Jupyter Lab, Jupyter Notebook, Google Colab, and Visual Studio Code with the Jupyter plugin.

Let's see how Datapane and Jupyter Notebook can build data-powered apps, all without disrupting your workflow.

import datapane as dp
import altair as alt
from vega_datasets import data

Enhancing Notebooks

Datapane Blocks are useful and they can be embedded straight into your notebook.

Interactive DataFrames

The notebook journey often begins by loading in a dataset and displaying it for a quick sanity check. Something like the following:

That's not bad, but it could be much better. Let's wrap our DataFrame in Datapane's dp.DataTable block and see what happens.

df = data.iris()

Our DataFrame is now interactive. We can explore it with filters, sorting, export options, and even run SQL queries against the data.

Adding structure with Tabs

Notebooks don't have to be a flood of in/out cells that are viewed from top to bottom. We can add depth to our notebooks with tabs.

Let's create a scatter plot with our dataset from earlier...

fig = (
    .encode(x="petalLength:Q", y="petalWidth:Q", color="species:N")

... and bring them both together with a dp.Select block.

    blocks =[
        dp.Plot(fig, label="Plot"),
        dp.DataTable(df, label="Data")

Now we have an interactive plot, and we can switch to that same interactive data explorer from earlier by clicking the "Data" tab.

Add even more Blocks

Enhance your data reports with Datapane's Blocks, which includes the handy dp.BigNumber block.

        heading="Percentage points",

Convert Notebooks to Reports

Data analysis often begins in a Jupyter Notebook, and once complete, we need to share our insights.

Some recipients may be comfortable with an .ipynb file, and in those instances, you could just send your notebook over and still benefit from Datapane's enhancements.

But in most cases, you will want to turn your notebook into something presentable and accessible. With Datapane, all it takes is a single line of code.

view = dp.View.from_notebook()

Datapane will automatically detect your cells and convert them to a set of blocks which can be saved as a report.

dp.upload_report(view, "My Report")

Iris analysis to report

Opt-in or opt-out

By default, notebook-to-report conversion will include all markdown and supported cell output. This is the easiest and quickest way to turn your notebook into an report.

In this mode, you can explicitly exclude cells with the cell tag dp-exclude.

Exclude cells

In some cases, it is preferable to only include cells of interest. This can be achieved by setting opt_out to False, e.g.:

blocks = dp.Blocks.from_notebook(opt_out=False)

In this mode, you can explicitly include supported cells with the cell tag dp-include.

Include cells

Display input code

You may want to display the input code for a particular cell in your report. Datapane has you covered. You can include code cells with the cell tag dp-show-code.

Show code

Let's do this for the cell below: