Jupyter Notebook Guide: The Data Scientist's Favorite Tool
โก Quick Answer
A complete Jupyter Notebook guide for 2026: installation, essential shortcuts, best practices, and how data scientists use Jupyter for exploration, analysis, and sharing.
Get more content like this on Telegram!
Daily AI tips, notes & resources โ free
Advertisement
Jupyter Notebook Guide: The Data Scientist's Favorite Tool
Jupyter Notebook is an interactive coding environment that runs code in cells and shows output โ charts, tables, text โ directly beneath each one, making it the standard tool for Python data exploration. Think of it as a lab notebook where the code and the results of running it live on the same page, instead of scattered across a terminal and a separate editor.
Data exploration is fundamentally different from application development. You're not building something from a spec โ you're asking questions and following the answers. Cell-by-cell execution, inline visualizations, and markdown explanation all serve that workflow in ways a traditional IDE doesn't.
This guide covers installation, the interface, keyboard shortcuts, and the best practices that separate a reproducible notebook from a fragile one.
Installation and Setup
Option 1: JupyterLab (Recommended)
pip install jupyterlab
jupyter labJupyterLab opens in your browser at http://localhost:8888. It's the modern interface with file browser, multiple tabs, and extensions.
Option 2: Classic Jupyter Notebook
pip install notebook
jupyter notebookOption 3: Google Colab (No Installation)
Go to colab.research.google.com. Free, cloud-based, no setup. For getting started quickly without local installation, Colab is the fastest path.
Option 4: Anaconda Distribution
Anaconda installs Python, Jupyter, and the full data science stack (pandas, NumPy, matplotlib, scikit-learn) in one installer. Good for beginners who want everything set up correctly without individual pip install commands.
The Notebook Interface
A Jupyter notebook is a sequence of cells. Each cell is either:
- Code cell: Contains Python code; executing it runs the code and displays output below
- Markdown cell: Contains formatted text, equations, images, and headings
- Raw cell: Unformatted content (rarely used)
Running Cells
| Action | Shortcut |
|---|---|
| Run cell and move to next | Shift + Enter |
| Run cell and stay | Ctrl + Enter |
| Run cell and insert new below | Alt + Enter |
Modes
Command mode (press Esc): Navigate between cells, change cell types, insert/delete Edit mode (press Enter): Edit cell content
Essential Keyboard Shortcuts
Command Mode (Esc first)
| Shortcut | Action |
|---|---|
A | Insert cell above |
B | Insert cell below |
D, D | Delete cell (press D twice) |
Z | Undo delete |
M | Convert to Markdown cell |
Y | Convert to Code cell |
Shift + Up/Down | Select multiple cells |
Shift + M | Merge selected cells |
Edit Mode (Enter first)
| Shortcut | Action |
|---|---|
Tab | Code completion |
Shift + Tab | Show function signature |
Ctrl + / | Toggle comment |
Ctrl + Z | Undo |
Learning these shortcuts makes Jupyter feel fast. Without them, it feels slow.
A Complete Data Exploration Example
This is what a real Jupyter data analysis looks like. Each cell represents a step in the exploration:
Cell 1: Setup
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from pathlib import Path
# Display settings
pd.set_option("display.max_columns", 50)
pd.set_option("display.float_format", "{:.2f}".format)
plt.style.use("seaborn-v0_8-whitegrid")
sns.set_palette("husl")
print("Libraries loaded")Cell 2: Load Data
# Load Titanic dataset (classic for learning)
df = pd.read_csv("titanic.csv")
print(f"Shape: {df.shape}")
df.head()Output displays as a formatted HTML table directly in the notebook.
Cell 3: Overview
print("=== DATASET INFO ===")
df.info()
print("\n=== MISSING VALUES ===")
missing = df.isnull().sum()
print(missing[missing > 0])
print("\n=== SURVIVAL RATE ===")
print(f"{df['Survived'].mean():.1%} survived")Cell 4: Visualization
fig, axes = plt.subplots(1, 3, figsize=(15, 5))
# Survival by class
df.groupby("Pclass")["Survived"].mean().plot(kind="bar", ax=axes[0], color="steelblue")
axes[0].set_title("Survival Rate by Class")
axes[0].set_ylabel("Survival Rate")
# Age distribution by survival
df[df["Survived"] == 1]["Age"].hist(ax=axes[1], alpha=0.7, label="Survived", bins=20)
df[df["Survived"] == 0]["Age"].hist(ax=axes[1], alpha=0.7, label="Died", bins=20)
axes[1].set_title("Age Distribution")
axes[1].legend()
# Fare distribution
df["Fare"].hist(ax=axes[2], bins=30)
axes[2].set_title("Fare Distribution")
plt.tight_layout()
plt.show()The charts appear inline directly below the cell โ no separate window.
Useful Jupyter Features
Magic Commands
Magic commands are special Jupyter commands prefixed with % (line magic) or %% (cell magic):
# Time a single line
%timeit sum(range(1000))
# Time an entire cell
%%timeit
total = 0
for i in range(1000):
total += i
# Run a shell command
!pip install pandas
# Display all variables
%whos
# Load external script
%run my_script.py
# Show matplotlib plots inline
%matplotlib inline
# Show interactive plots
%matplotlib widgetRich Outputs
# Display DataFrames as styled HTML
df.head().style.highlight_max(axis=0)
# Display images
from IPython.display import Image, display
display(Image("chart.png"))
# Display HTML
from IPython.display import HTML
HTML("<h2 style='color:blue'>HTML in a notebook</h2>")
# Display LaTeX equations
from IPython.display import Latex
Latex(r"$$\frac{d}{dx} e^x = e^x$$")Markdown Cells โ Telling the Story
Good notebooks alternate between code and explanation. Markdown cells provide context:
## Exploratory Analysis
Before building any models, let's understand the data.
### Key findings so far:
- **38% survival rate** overall
- First class passengers survived at **63%**, third class at only **24%**
- Women survived at **74%**, men at **19%**
These patterns suggest class and gender are strong predictors.The ability to mix explanation with code is what makes Jupyter notebooks shareable as research documents.
Working with pandas in Jupyter
pandas was designed with Jupyter in mind. Several features are specifically useful in notebooks:
# DataFrames display as formatted tables
df.head(10)
# Conditional styling
df.style.background_gradient(subset=["Fare"], cmap="RdYlGn")
# Describe with colored output
df.describe().style.highlight_max()
# Interactive sorting and filtering
df.sort_values("Fare", ascending=False).head(10)For a complete pandas guide, see our Python data science roadmap.
Jupyter Best Practices
1. Restart and Run All Before Sharing
Notebooks accumulate state from out-of-order cell execution. Before sharing or submitting, always restart the kernel and run all cells in order (Kernel โ Restart & Run All). This ensures the notebook is reproducible.
2. Use Descriptive Cell Structure
# Bad: monolithic cell
df = pd.read_csv("data.csv")
df.dropna(inplace=True)
df["new_col"] = df["col1"] * df["col2"]
result = df.groupby("category")["new_col"].sum()
result.plot()# Good: one concern per cell
# Cell 1: Load
df = pd.read_csv("data.csv")
print(f"Loaded {len(df)} rows")# Cell 2: Clean
df.dropna(inplace=True)
print(f"After cleaning: {len(df)} rows")# Cell 3: Transform
df["revenue"] = df["price"] * df["quantity"]# Cell 4: Analyze and visualize
by_category = df.groupby("category")["revenue"].sum()
by_category.plot(kind="bar", title="Revenue by Category")3. Name Your Variables Clearly
In interactive exploration, it's tempting to use df2, df_new, df_temp. These make notebooks hard to understand. Use descriptive names: df_cleaned, df_by_month, model_results.
4. Export Notebooks as Reports
# Export to HTML (shareable report)
jupyter nbconvert --to html analysis.ipynb
# Export to PDF
jupyter nbconvert --to pdf analysis.ipynb
# Export to Python script
jupyter nbconvert --to script analysis.ipynbGoogle Colab Tips
For Colab-specific workflows:
# Mount Google Drive
from google.colab import drive
drive.mount('/content/drive')
# Access file
df = pd.read_csv('/content/drive/MyDrive/data/my_file.csv')
# Install packages
!pip install yfinance
# Use free GPU
# Runtime โ Change runtime type โ GPU
import torch
print(torch.cuda.is_available()) # True if GPU allocatedColab is especially useful for machine learning experiments that need GPU โ something local machines often can't provide. For ML projects using Colab, see our Python machine learning beginner guide.
Further Reading
- How I Learned Python in 3 Months and Got a Job: My Honest Story
- The Python Libraries Every Developer Must Know in 2025
- Python File Handling Guide: Read, Write, Process Any File Type
- Python for Absolute Beginners: Your First 30 Days Roadmap (2025)
- How to Use Python for Data Science (Complete 2025 Roadmap)
- Recommendation Systems Explained: How Netflix and Amazon Know What You Want
- Tailwind CSS vs Bootstrap in 2025: The Final Verdict
- Best Machine Learning Courses in 2025: Ranked After Taking Them All
Advertisement
๐ฌ DiscussionPowered by GitHub Discussions
Frequently Asked Questions
Problem Solver and Cloud Expert
Solves complex infrastructure challenges and architects reliable, scalable cloud deployments for every project. Shamshur Rahman keeps AiTechWorldsโ hosting and cloud infrastructure fast, resilient, and cost-efficient.
Not sure yet? Ask AI about this article
Get an instant, unbiased AI summary of โJupyter Notebook Guide: The Data Scientist's Favorite Toolโ.
Advertisement
Related Articles
The Python Libraries Every Developer Must Know in 2026
The essential Python libraries for 2026: from requests and pandas to FastAPI and LangChain โ what each does, when to use it, and how to get started quickly.
Django vs Flask in 2026: Which Framework Should You Learn?
An honest Django vs Flask comparison for 2026 โ which Python framework to learn first, when each excels, and why FastAPI has changed the equation.
FastAPI Tutorial: Building Your First REST API in 30 Minutes
A hands-on FastAPI tutorial for beginners: build a fully functional REST API in 30 minutes with CRUD endpoints, request validation, and automatic docs.
How I Learned Python in 3 Months and Got a Job: My Honest Story
A real story of learning Python fast and landing a developer job in 90 days โ what worked, what failed, and the exact roadmap to learn Python quickly.