10 Little‑Known Jupyter Tricks That Can Double Your Productivity
This article walks through ten hidden Jupyter Notebook features—including magic commands, terminal integration, shortcut keys, markdown styling, collapsible headings, nbconvert exporting, and tab completion—showing how each can streamline debugging, documentation, and reporting to save roughly an hour of work per day.
Variable locator: %who & %whos
List variables in the current namespace and display their type, size, and value.
import numpy as np
data = np.array([1, 2, 3])
%whos # output: data numpy.ndarray (3,) [1 2 3]Speed judge: %timeit
Compare execution speed of code snippets. The magic command runs the expression repeatedly and reports the average time.
%timeit [i**2 for i in range(1000)]
%timeit np.square(np.arange(1000))Using %%timeit (double percent) measures the whole cell.
Terminal connector: ! command
!ls
!pip install pandas -i https://pypi.tuna.tsinghua.edu.cn/simple
!cat data.csvCode exporter: %%writefile
%%writefile my_utils.py
def clean_data(df):
return df.dropna().reset_index(drop=True)Verify the export:
!cat my_utils.pySyntax dictionary: ? & ??
len?
pd.DataFrame??Shortcut keys "triple kill"
Shift + Enter – run cell and move to the next cell.
Ctrl + Enter – run cell and stay in place.
Alt + Enter – run cell and insert a new cell below.
Markdown beautifier
# Heading 1 (Report Title)
## Heading 2 (Section Title)
- 1. Data cleaning
- 2. Model training
$y = wx + b$ # linear regression formula
Large‑note collapser
Installation for Jupyter Notebook
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --userRestart Jupyter and enable "Collapsible Headings" in the Nbextensions panel.
Installation for Jupyter Lab (≥3.0)
Search for "Collapsible Headings" in the Extension Manager and install.
Toggle collapse by clicking the triangle next to a heading or pressing T in command mode.
Export purifier: nbconvert + tags
Tagging
remove_input– hide code, keep output. remove_output – hide output, keep code. remove_cell – delete the entire cell.
Export commands
# Export HTML without code cells
jupyter nbconvert --to html --TagRemovePreprocessor.remove_input_tags="{'remove_input'}" notebook.ipynb
# Export PDF (requires LaTeX)
jupyter nbconvert --to pdf --TagRemovePreprocessor.remove_cell_tags="{'remove_cell'}" notebook.ipynbSmart prompt: Tab key
Auto‑complete variable and function names.
Show all methods of an object (e.g., df. + Tab).
Press Shift+Tab to display the function’s docstring in a tooltip.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Data STUDIO
Click to receive the "Python Study Handbook"; reply "benefit" in the chat to get it. Data STUDIO focuses on original data science articles, centered on Python, covering machine learning, data analysis, visualization, MySQL and other practical knowledge and project case studies.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
