2.6. Creating a notebook
Notebooks are an easy way to start developing code and working with data.
They are interactive documents split up into cells, each cell contains either code or text, and when run display the output below.
The output can be printed statements, displaying data, or charts.
This allows you to show the output of your code in the same place you write it, making it easier to write code and share results.
Why use Jupyter Notebooks?
-
Perfect for Exploratory Analysis
You can run small code blocks step-by-step and instantly see results without rerunning the whole script. -
Readable & Shareable
Combine commentary with code so others can follow your thinking - not just see the final output. -
Supports Visualisation
Display charts directly in-line with your code using libraries like such as plotly. -
Great for Prototyping
Test out an idea quickly before moving it into a more robust Python script or production pipeline. -
Version Control Friendly
When paired with Git/GitHub, you can track changes to your notebooks and collaborate with others.
How to use Jupyter Notebooks
Create a new file in your directory and give it the extension .ipynb.
Inside the notebook select kernel
Create new cell, add any code (ie, print("Hello World")), the first time running will bring up a promp to install any libraries required for Jupyter. Click OK.
Once installed code can be written and run in cells individually.