Jupyter
Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more.
JupyterLab is the next-generation user interface for Project Jupyter. It offers all the familiar building blocks of the classic Jupyter Notebook (notebook, terminal, text editor, file browser, rich outputs, etc.) in a flexible and powerful user interface.
Setup Jupyter Notebook
Install Jupyter Notebook with the following command. Alternatively, it is already packaged and ready to use with the Anaconda distribution.
Starting the Notebook Server:
Open a specific Notebook:
Setup JupyterLab
Install JupyterLab with the following command.
Launch by running:
Useful JupyterLab extensions
- JupyterLab-LSP: adds code assistance capabilities to JupyterLab
- Debugger: a proper debugger
- jupyterlab-toc: auto-generates a table of contents in the left area when you have a notebook or markdown document open
- jupyterlab_spellchecker: spellchecker for markdown cells
Here is a curated list of JupyterLab extensions
Useful IPython commands
The %matplotlib inline
command is an IPython magic function that sets the output of plotting commands to be displayed inline within frontends like the Jupyter notebook, directly below the code cell that produced it. The resulting plots will then also be stored in the notebook document.
The figsize
sets the figure size
Globaly set the scale of text and font for Seaborn
Add parent folder to path
This is useful so you can import into the notebook utility functions from a parent directory.
# Add parent directory to Python path
import os
import sys
module_path = os.path.abspath(os.path.join('..'))
if module_path not in sys.path:
sys.path.append(module_path)
# Import function fun1 from modeule file1 in directory utils
from utils.file1 import fun1
Here is another alternative.
Supose you have the following diretory structure.
We want to use our functions inside utils.py
from our example.ipynb
notebook.