Lesson 3 · Data visualisation in python
How to Set Up Python and Jupyter Notebook for Data Visualization Beginners
Welcome! This lesson will guide you through setting up a Jupyter Notebook to visualize data using Python. No experience needed. You will learn how to: Run…
- CourseData visualisation in python
- Lesson3 of 34
- Video12 min
- FormatJupyter notebook · 16 code cells
What you'll learn
Data
No separate download needed — the notebook creates or downloads everything it uses.
📓 Full notebook
Download .ipynbPython Jupyter Notebook Setup for Data Visualization#
Welcome! This lesson will guide you through setting up a Jupyter Notebook to visualize data using Python. No experience needed.
You will learn how to:
- Run Python code cells in Jupyter
- Import popular data visualization libraries
- Download and preview real-world datasets
- Make your first plot of real data
import warnings
warnings.filterwarnings("ignore")
What is a Jupyter Notebook?#
A Jupyter Notebook lets you run and test Python code in small, easy blocks called cells.
- You can mix code and text to organize your work
- All your work appears in one place
# This is a comment. It will not run.
print("Hello, data world!")
name = input("What is your name? ")
print("Welcome, " + name + "!")
Setting Up for Data Visualization#
Data visualization is a way to make numbers and patterns easier to see.
We will use two popular Python libraries:
- pandas (reads and works with data tables)
- matplotlib (makes charts and plots)
import pandas as pd
import matplotlib.pyplot as plt
# Data setup
url = "https://raw.githubusercontent.com/jbrownlee/Datasets/master/airline-passengers.csv"
df = pd.read_csv(url)
print("Data shape:", df.shape)
df.head()
What is in this Data?#
This table has two columns:
- Month: The year and month.
- Passengers: The number of airline passengers in that month.
plt.figure(figsize=(10,5))
plt.plot(df["Month"], df["Passengers"])
plt.title("Airline Passengers Over Time")
plt.xlabel("Month")
plt.ylabel("Number of Passengers")
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
# What if you want just one column?
months = df["Month"]
months.head()
# Checking for missing values
missing = df.isnull().sum()
print("Missing values per column:")
print(missing)
# Quick column stats
print(df["Passengers"].describe())
# Adding a new column
df["Year"] = df["Month"].apply(lambda x: x.split("-")[0])
df.head()
# Group by year
yearly = df.groupby("Year")["Passengers"].sum()
print(yearly)
# Bar chart of total passengers per year
yearly.plot(kind="bar", figsize=(8,4), color="skyblue")
plt.title("Total Passengers Each Year")
plt.ylabel("Passengers")
plt.xlabel("Year")
plt.show()
# Safe access: What if column does not exist?
try:
print(df["NotARealColumn"])
except KeyError:
print("Column not found!")
# Mini-project: Find the month with most passengers
max_row = df.loc[df["Passengers"].idxmax()]
print("Month with most passengers:")
print(max_row)
# Extra: Save a plot as a file
plt.figure(figsize=(6,3))
plt.plot(df["Month"], df["Passengers"], color="green")
plt.title("Monthly Air Passengers")
plt.tight_layout()
plt.savefig("airline_passengers_plot.png")
print("Plot saved as airline_passengers_plot.png")
# Practice: Try your own data
custom_url = input("Enter a CSV URL for another time series dataset, or press Enter to use the same one: ")
if not custom_url:
custom_url = "https://raw.githubusercontent.com/jbrownlee/Datasets/master/shampoo.csv"
custom_df = pd.read_csv(custom_url)
print("Preview of your chosen dataset:")
print(custom_df.head())
Challenge: Explore and Plot Another Dataset#
Can you find the biggest value in a new column?
- Try using describe() and idxmax() on your practice dataset.
- Make a line plot of any numerical data.
Remember, experiment and see what happens!
Recap#
Great job! Here is what you have done:
- Learned to run Python cells in Jupyter
- Loaded real data with pandas
- Made and customized several charts
- Practiced exploring new datasets
Keep trying new datasets and plots to build your skills.
Thanks and Next Steps#
Practicing with your own data is the fastest way to learn.
Try a challenge from this lesson, or check out more tutorials on our channel.
Please like, subscribe, or leave a comment if this helped you!
Found this useful?
All lessons, notebooks and datasets here are free. If they helped you, a coffee keeps new lessons coming.



