Quick Reference

Last updated on 2026-08-27 | Edit this page

Keyboard Shortcuts


Running cells:

Action Shortcut
Run cell Ctrl+Enter
Run cell and move down Shift+Enter
Run all cells Menu: Run → Run All Cells

Editing:

Action Shortcut
New cell below Ctrl+Shift+B
New cell above Ctrl+Shift+A
Convert to code Escape then Y
Convert to markdown Escape then M
Delete cell Select cell, Escape, D, D
Undo Ctrl+Z
Save Ctrl+S

Navigation:

Action Shortcut
Go to line Ctrl+G
Find Ctrl+F
Find and replace Ctrl+H

pandas Quick Reference

Loading data:

PYTHON

import pandas as pd
df = pd.read_csv('file.csv')
df = pd.read_excel('file.xlsx')
df = pd.read_json('file.json')

Exploring:

PYTHON

df.head()              # First 5 rows
df.tail()              # Last 5 rows
df.shape               # (rows, columns)
df.info()              # Data types
df.describe()          # Summary statistics
df['column'].unique()  # Unique values

Selecting:

PYTHON

df['column']           # One column
df[['col1', 'col2']]   # Multiple columns
df[df['age'] > 25]     # Filter
df.iloc[0]             # First row
df.loc[df['id'] == 5]  # By label

Modifying:

PYTHON

df['new'] = df['a'] + df['b']        # Add column
df.rename(columns={'old': 'new'})    # Rename
df.drop('col', axis=1)               # Remove column
df.fillna(0)                         # Fill missing
df.groupby('cat').mean()             # Group by

NumPy Quick Reference

Create arrays:

PYTHON

import numpy as np
arr = np.array([1, 2, 3])
arr = np.zeros((3, 4))
arr = np.ones((3, 4))
arr = np.linspace(0, 10, 100)
arr = np.random.randn(100)

Operations:

PYTHON

arr.shape              # Dimensions
arr.mean()             # Average
arr.std()              # Standard deviation
arr.min(), arr.max()   # Min, max
arr * 2                # Multiply
arr[0:5]               # First 5
arr[arr > 5]           # Filter

matplotlib Quick Reference

Basic plot:

PYTHON

import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [1, 4, 2, 3]
plt.plot(x, y)
plt.title('Title')
plt.xlabel('X')
plt.ylabel('Y')
plt.show()

Plot types:

PYTHON

plt.plot(x, y)                    # Line
plt.scatter(x, y)                 # Points
plt.hist(data, bins=30)           # Histogram
plt.bar(categories, values)       # Bar chart

Subplots:

PYTHON

fig, axes = plt.subplots(2, 2)
axes[0, 0].plot(x, y)
axes[0, 1].scatter(x, y)
plt.show()

IPython Magic Commands

PYTHON

%timeit code                # Time execution
%matplotlib inline          # Show plots inline
%pwd                        # Current directory
%ls                         # List files
%run script.py              # Run file
%whos                       # List variables
%clear                      # Clear output

Sagehen HPC Storage

Path Size Backed Up Purpose
/rhome/<myusername> 100 GB Yes Home directory
/bigdata/lab/<labname> 1 TB Yes Lab shared storage
/scratch/username SSD No Fast temporary

Common Errors

NameError: name ‘x’ is not defined - Cause: Variable not created yet - Fix: Run cell that creates x first

ModuleNotFoundError: No module named ‘numpy’ - Cause: Package not installed - Fix: pip install numpy in terminal, then restart kernel

FileNotFoundError: no such file - Cause: Wrong file path - Fix: Use absolute path or verify filename

Cell hangs - Cause: Infinite loop or too much data - Fix: Click stop button or Kernel → Interrupt

Conda Commands

BASH

# List environments
conda env list

# Create environment
conda create --name myenv python=3.11 numpy pandas

# Activate
conda activate myenv

# Install packages
conda install numpy
pip install package

# Export for sharing
conda env export > environment.yml

# Create from export
conda env create -f environment.yml

Converting Notebooks

To Python script:

BASH

jupyter nbconvert --to script notebook.ipynb

To HTML:

BASH

jupyter nbconvert --to html notebook.ipynb

To PDF:

BASH

jupyter nbconvert --to pdf notebook.ipynb

Reproducibility Checklist

Getting Help