Pandas Tutorial
Creating Objects
Viewing Data
Selection
Manipulating Data
Grouping Data
Merging, Joining and Concatenating
Working with Date and Time
Working With Text Data
Working with CSV and Excel files
Operations
Visualization
Applications and Projects
Jupyter Notebook is a highly popular tool among data scientists and researchers for creating and sharing documents that contain live code, equations, visualizations, and narrative text. Let's go through a comprehensive guide on how to use Jupyter Notebook:
Using pip:
pip install jupyter
Using Anaconda:
It's often simpler to install Jupyter via Anaconda, especially for beginners. Once you have Anaconda installed, Jupyter comes bundled with it.
In your terminal or command prompt, simply type:
jupyter notebook
This will launch Jupyter in your default browser.
Once launched, you'll be in the Jupyter Dashboard:
To create a new notebook, click on the "New" button and select a kernel, typically "Python 3".
Jupyter operates with "cells". A cell can be code, markdown, or raw text.
Executing a cell: Press Shift + Enter
or click on the "Run" button.
Edit Mode: Allows you to type code/text into a cell. Indicated by a green border. Enter this mode by pressing Enter
or clicking on a cell.
Command Mode: Navigate around the notebook using keyboard shortcuts. Indicated by a blue border. Press Esc
to enter this mode.
a
(in Command Mode)b
(in Command Mode)dd
(in Command Mode)m
(in Command Mode)y
(in Command Mode)Jupyter supports Markdown for creating structured documents.
For example, # This is a header
in a Markdown cell becomes a header.
Jupyter also supports LaTeX for mathematical equations. Wrap your equation with $
for inline and $$
for block:
$e^{i\pi} + 1 = 0$
$$e^{i\pi} + 1 = 0$$
These are special commands that provide useful features:
%run
: Runs a python script.
%load
: Inserts the code from an external script.
%timeit
: Measures the execution time of the code in the current cell.
Jupyter has built-in support for displaying plots from libraries like Matplotlib. Just make sure to include the line %matplotlib inline
at the top of your notebook to display plots within the notebook.
Jupyter has a vast ecosystem of extensions. Some popular ones can be installed via the Jupyter-contrib extensions package:
pip install jupyter_contrib_nbextensions jupyter contrib nbextension install --user
Jupyter notebooks can be exported in various formats like PDF, HTML, and Python scripts via the File -> Download as
menu.
Simply close the browser tab and go back to the terminal. Press Ctrl+C
and confirm to shut down the Jupyter server.
Jupyter Notebook is a powerful tool, especially when combined with Python's data science stack: Pandas, Numpy, Scikit-learn, Matplotlib, etc. This guide provides the basics to get started, but there's much more to explore!
Data visualization in Jupyter using Matplotlib and other libraries:
import matplotlib.pyplot as plt %matplotlib inline # Create a simple plot x = [1, 2, 3, 4, 5] y = [2, 4, 6, 8, 10] plt.plot(x, y) plt.show()
Interactive widgets and dashboards in Jupyter:
from ipywidgets import interact # Create an interactive slider @interact(x=(0, 10)) def square(x): print(f'Square of {x} is {x*x}')