Jupyter Notebook is the IDE most data scientists spend 80% of their time in, yet most users only know the basics. These 15 advanced features will make you dramatically more productive — from profiling slow code to building interactive widgets without writing any JavaScript.
1. Magic Commands
IPython magic commands start with % (line magic) or %% (cell magic):
%timeit model.predict(X_test) # benchmark a line
%%timeit # benchmark entire cell
%time model.fit(X_train, y_train) # time once (not averaged)
%run myscript.py # run a Python script in Jupyter
%who # list all variables
%whos # list variables with types and sizes
%reset # clear all variables
%history # show command history
%matplotlib inline # show plots inline
%matplotlib widget # interactive plots (requires ipympl)
2. Memory and Performance Profiling
pip install line_profiler memory_profiler
%load_ext line_profiler
%load_ext memory_profiler
# Line-by-line time profiling
%lprun -f my_function my_function(X)
# Line-by-line memory profiling
%mprun -f my_function my_function(X)
# Quick memory snapshot
%memit model.fit(X_train, y_train)
3. Inline Shell Commands
!pip install pandas --quiet
!ls data/
!git log --oneline -10
# Capture output into Python variable
files = !ls *.csv
print(files) # Python list of filenames
4. Interactive Widgets with ipywidgets
pip install ipywidgets
import ipywidgets as widgets
from IPython.display import display
@widgets.interact(n_estimators=(10, 500, 10), max_depth=(1, 20, 1))
def train_and_evaluate(n_estimators=100, max_depth=5):
model = RandomForestClassifier(n_estimators=n_estimators, max_depth=max_depth)
model.fit(X_train, y_train)
acc = model.score(X_test, y_test)
print(f"Accuracy: {acc:.4f}")
This creates interactive sliders that retrain the model live — no need to write a web app.
5. Rich Display Objects
from IPython.display import HTML, Markdown, Image, Audio, display
# Display formatted HTML
display(HTML('''
Model Training Complete
Accuracy: 94.2%
'''))
# Display Markdown
display(Markdown("## Results
**Best model**: Random Forest
- Accuracy: 94.2%
- F1: 0.93"))
# Style a DataFrame
df.style.background_gradient(cmap='RdYlGn').format('{:.2%}')
6. Useful Keyboard Shortcuts
In command mode (press Esc): A = insert cell above, B = insert cell below, D+D = delete cell, M = convert to Markdown, Y = convert to code, Shift+Up/Down = select multiple cells, Shift+M = merge selected cells, L = toggle line numbers, O = toggle output. In edit mode: Ctrl+Shift+- = split cell at cursor, Tab = autocomplete, Shift+Tab = show docstring.
7. Displaying Multiple Outputs
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
# Now all expressions in a cell show output (not just the last one)
df.shape
df.dtypes
df.describe()
8. Autoreload – Auto-import Changed Modules
%load_ext autoreload
%autoreload 2
# Now if you edit mymodule.py and re-run a cell, changes are picked up
from mymodule import my_function
my_function() # uses updated version automatically
This is essential when developing reusable code in .py files alongside a notebook.
9. Suppress Output Programmatically
from IPython.utils import io
with io.capture_output() as captured:
model.fit(X_train, y_train) # suppress verbose sklearn output
print(f"Training complete. Output: {captured.stdout[:100]}")
10. Progress Bars with tqdm
from tqdm.notebook import tqdm # notebook version has nice visual bar
import time
for i in tqdm(range(100), desc="Training"):
time.sleep(0.05)
# Wrap any iterable
for batch in tqdm(data_batches, desc="Processing batches"):
process_batch(batch)
11. Watermark – Document Your Environment
pip install watermark
%load_ext watermark
%watermark -v -p numpy,pandas,sklearn,torch --machine
Outputs Python version, package versions, and hardware info — essential for reproducible research notebooks.
12. JupyterLab Features
JupyterLab (the successor to classic Jupyter) adds: file browser sidebar, multi-panel layout (notebook + terminal + file editor simultaneously), cell execution tracking, Git integration via jupyterlab-git, and a variable inspector. Install with pip install jupyterlab and launch with jupyter lab.
Conclusion
The gap between a basic Jupyter user and a power user is mostly just knowing these features exist. Start with %timeit and %memit to profile your code, add %autoreload to your standard notebook header when developing .py modules, and try ipywidgets for any parameter you currently change manually and re-run. Each of these takes 5 minutes to learn and saves hours over a data science career.


