Data Science Notebooks: A Must-Have in Your Team’s Arsenal

Sharin Khander
4 min readNov 29, 2023

--

Have you ever wondered how data scientists transform raw code into actionable insights about users? Enter data science notebooks, or as some call them, “code notebooks.” These tools provide a bridge from a jumble of code to a neatly formatted, visual representation of iterative code blocks. In this post, we’ll unravel the mystery behind code notebooks, exploring why they’ve become a staple for data teams and developers alike.

Data Science notebooks — or just “code notebooks” — help you go from this blob of code with churn data:

Sharin Khander pandas

To this nicely formatted, iterative, visual set of code blocks:

To this beautifully visualized graph that tells a story:

sharinkhander pandas data

Understanding Code Files vs. Notebooks

Your typical developer writes code organized into files. When executed, the entire code runs sequentially, producing a desired output. However, for data analysts and scientists, the game is different. Their work involves iterative tasks like querying data, cleaning it, modeling, and charting. Unlike developers, they need constant intermediate feedback for each line of code.

The Notebook Revolution

Before 2011, data teams wrote code in files like everyone else. Then came the iPython Notebook, a game-changer. The notebook approach allows you to write a block of code, run it, observe the output, and proceed to the next block. What makes notebooks invaluable?

  1. Iterative Nature: Run code step by step, ensuring each part works before moving on.
  2. Visual Appeal: Integrated tables, charts, and text enhance code visualization.
  3. Organizational Excellence: Notebooks function like presentations — name each cell, reorder them, and add markdown for storytelling.

Peeling Back the Layers of a Notebook

Let’s break down the original code block querying churn data. In a notebook, a data scientist can import libraries, upload data, visualize it, filter it, and validate the results — all step by step. While this could be done in a single file, the notebook’s iterative nature allows for gradual progress, ensuring each step achieves the intended outcome.

A huge key advantage of notebooks is their visual aspect. They allow us to easily view well-formatted tables, as seen above, and even create code to visualize data in charts. Crafting stories is a crucial aspect of the vital role data teams play.

Notebooks: More than a Panacea

Despite their advantages, notebooks have their critics. Some argue they’re primarily suited for exploration, not production. However, their value in exploratory data work is undeniable. Visual appeal, organization, and storytelling capabilities make them indispensable for data teams.

Evolution of Notebooks: A Brief History

The iPython Notebook, born in 2011, was not the first notebook interface. Mathematica, dating back to 1988, was the pioneer. The notebook concept acts as a frontend for basic code, with the kernel — the computational engine — executing code and formatting results for visual presentation.

Diversity in Kernels and Deployment Models

Initially Python-centric, notebooks now support various languages with interchangeable kernels. The Jupyter notebook, formerly iPython, has become the go-to, with over 100 official kernels available. As notebooks extend beyond data science, languages like Java, JavaScript, Scala, and Go have joined the fray.

Running Notebooks: Local or in the Cloud?

Jupyter, an open-source project, allows local installation for those technically inclined. However, cloud-hosted solutions like Hex offer enhanced collaboration and powerful kernels. The choice depends on individual needs, with cloud deployment gaining traction for its convenience and capabilities.

Unravel the potential of data science notebooks, whether you’re cleaning and categorizing data, visualizing trends, prototyping ML models, or crafting compelling data stories.

More Reading:

  • At Netflix, engineers rely extensively on notebooks in their machine learning systems, possibly more so than anyone else.
  • One of the first and my favorite in-depth look at the topic from Uber.

--

--

Sharin Khander
Sharin Khander

Written by Sharin Khander

Once an engineer, now a product manager. I like to simplify the complex and the technical.