Getting More Out of Your Jupyter Notebooks

Shortcuts

Switches

!pip show ipythonName: ipython
Version: 7.19.0
Summary: IPython: Productive Interactive Computing
Home-page: https://ipython.org
Author: The IPython Development Team
Author-email: ipython-dev@python.org
License: BSD
Location: /usr/lib/python3.8/site-packages
Requires:
Required-by: jupyter-console, ipykernel
?list
Docstring
%system pip show ipython['Name: ipython',
'Version: 7.19.0',
'Summary: IPython: Productive Interactive Computing',
'Home-page: https://ipython.org',
'Author: The IPython Development Team',
'Author-email: ipython-dev@python.org',
'License: BSD',
'Location: /usr/lib/python3.8/site-packages',
'Requires: ',
'Required-by: jupyter-console, ipykernel']
%timeit [i*i for i in range(50)]2.61 µs ± 228 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)string_s, integer_i, tuple_t = 'wololo', 4, (35, 42)
%who_ls tuple
['tuple_t']

Kernels

# Create a folder to host the virtual environment
!mkdir virtual_environments
# Move to the folder and create the virtual environment
!cd virtual_environments
!virtualenv my_env
# Activate the virtual environment
!source my_env/bin/activate
# Install ipykernel in the virtual environment
!pip install ipykernel
# Let Jupyter know there is a new kid on the block
!python -m ipykernel install --user --name=my_env
# List kernels installed
!jupyter kernelspec list
# Uninstall kernel
!jupyter kernelspec uninstall [kernelName]

Extensions

!pip install jupyter_contrib_nbextensions
!jupyter contrib nbextension install --user
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"

Final Thoughts

Photo by Greg Rakozy on Unsplash

Data Scientist

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store