Skip to content

Zebras in a Jupyter Notebook

nickslevine edited this page Dec 28, 2018 · 3 revisions

Zebras in a Jupyter Notebook

Zebras is built for analyzing data in notebooks. Observable is an excellent hosted option. However, if you want to work in a local environment, Jupyter notebooks are your best bet. This guide will explain how to get zebras up and running in a Jupyter notebook using a JavaScript kernel.


  1. Install Jupyter and IJavascript (the JS Jupyter kernel) - see the instructions on the IJavascript GitHub page here.

  2. Create a project directory and navigate to it in your terminal. Run:

npm init -y
npm install --save zebras jvl
jupyter lab
  1. In Jupyter Lab, create a new notebook using the JavaScript kernel. In a cell, run:
const z = require('zebras')
const {jvl} = require('jvl')


Load data from a csv file using z.readCSV(). Now you can manipulate and analyze it using zebras functions.

To visualize it, run jvl(), inputting a vega-lite spec, eg:

const spec = {
  data: {
    values: [
      {a: "A", b: 28}, {a: "B", b: 55}, {a: "C", b: 43},
      {a: "D", b: 91}, {a: "E", b: 81}, {a: "F", b: 53},
      {a: "G", b: 19}, {a: "H", b: 87}, {a: "I", b: 52}
  mark: "bar",
  encoding: {
    x: {field: "a", type: "ordinal"},
    y: {field: "b", type: "quantitative"}