Stop 03 · Python for Data ScienceTopics · 6/9

Jupyter Notebooks & Google Colab

Part of the Data Science Roadmap

In short

Notebooks let you run code a piece at a time and see tables and charts right below. Colab gives you one in the browser for free, no installation needed.

Interactive coding environments mixing code, output and notes — Jupyter runs locally, Colab runs in the browser with free GPU access, both standard for data science exploration and prototyping.

The mascot writes in a spiral notebook at a desk, ticking off each step with a pencil.

Think of it like this

Your rough notebook in class

In a rough notebook you solve a problem step by step, checking each answer before moving on. Cells work the same way. But scribble out of order and the page stops making sense, which is the main notebook trap.

Watch it happen

Run order is what counts

import pd
0
load df
1
clean df
2
plot
3

1/5Four cells, written top to bottom. Each one runs separately and remembers its results in memory.

The big ideas

What you need to know

Cells run one at a time

Shift+Enter runs a cell. The number in brackets shows the order things actually ran.

Markdown cells explain

Mix headings and notes between code so your notebook reads like a short report.

Colab is free and in the browser

Popular libraries come preinstalled, and you can save notebooks to Google Drive or GitHub.

Restart and run all

Before sharing, restart and run everything top to bottom to catch hidden state bugs.

See it in code

Walk through the code

python
1# Cell 1: install a package inside Colab2!pip install -q plotly3 4# Cell 2: check your Python version5import sys6print(sys.version)7 8# Cell 3: the last line of a cell is shown automatically9import pandas as pd10df = pd.DataFrame({"x": [1, 2, 3]})11df.describe()

1/3A ! runs a shell command. Handy for installing a missing library.

Three common notebook moves: shell commands with !, normal Python, and a table shown just by naming it last.

Save yourself the pain

Common mistakes

Oops

Sharing a notebook whose cells only work in the order you happened to run them.

Do this instead

Restart and run all before sharing. Fix anything that breaks.

Oops

Keeping important data only in Colab's temporary storage.

Do this instead

Colab's files disappear when the session ends. Save to Google Drive or download your outputs.

Your mission

Your first clean notebook

~20 min

Quick check

Your notebook works for you but fails for a friend at cell 5. What's the most likely cause?

Go deeper

  1. 1Set up both a local Jupyter environment and a Google Colab notebook.
  2. 2Practice mixing markdown notes with code cells to document your reasoning.
  3. 3Use Colab's free GPU runtime for a small deep learning experiment later in this roadmap.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge