Bonus Drop #98 (2025-09-14): Observable Notebooks Data Loaders Example

Looking At Historical IPOs

Boy howdy it has been a week.

Hopefully the Bonus Drop will take your mind off of (gestures wildly) for a bit as you peruse the source of a practical example of using a Python data loader in Observable Notebooks 2.0.

You can preview the finished build or clone the aforelinked repo and open up the index.html in Observable Desktop.

A quick TL;DR on data loaders before you leave…

Data loaders let notebooks run code ahead of time during the build process, rather than on-demand in the browser.

This is super useful when you want:

  • stable, repeatable snapshots of data
  • better performance (no re-fetching every time a notebook loads)
  • a way to pull in data from systems that aren’t just SQL databases

Right now, Observable supports Node.js and Python as interpreters for data loaders, with more planned later.

I have a larger example in the project folder (it slices and dices a PDF). This is the most basic example straight from Observable:

import platform
print(f"Hello from Python {platform.python_version()}!", end="")

This runs under Python and outputs a string. The result gets a name (hello) in the cell metadata that you can reference in JavaScript:

hello.toUpperCase()
// → "HELLO FROM PYTHON 3.12.3!"

Supported output formats include:

  • Text-based: text, json, csv, tsv, xml
  • Binary: arrow, parquet, blob, buffer
  • Media: jpeg, gif, webp, png, svg
  • Other: html (for server-rendered HTML)

Python data loaders require Python 3.12+, installed in one of:

  • .venv/bin/python3 (local venv)
  • /opt/homebrew/bin/python3 (Homebrew)
  • /opt/local/bin/python3 (MacPorts)
  • /usr/local/bin/python3 (official installer)
  • /usr/bin/python3 (system)

If there’s a .venv in your notebook directory (my project has one managed by uv), it’s used automatically.

You must manage dependencies yourself (via pip + requirements.txt).

Drop a note wherev if something is busted or you have any q’s.


FIN

Remember, you can follow and interact with the full text of The Daily Drop’s free posts on:

  • 🐘 Mastodon via @dailydrop.hrbrmstr.dev@dailydrop.hrbrmstr.dev
  • 🦋 Bluesky via https://bsky.app/profile/dailydrop.hrbrmstr.dev.web.brid.gy

☮️

Fediverse Reactions

One response to “Bonus Drop #98 (2025-09-14): Observable Notebooks Data Loaders Example”

  1. Drop #710 (2025-09-15): Monday Morning Grab Bag – hrbrmstr's Daily Drop Avatar

    […] spent way too much time adding WebR support to Observable Notebooks Data Loaders Example after composing yesterday’s Bonus Drop that there was no time left to gather themed […]

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.