Lesson 11 · Data Science Projects
Comprehensive Analysis and Visualization of Global Covid-19 Data Using Python
In this lesson, we will explore global Covid 19 data. You will learn how to analyze and visualize trends over time. Data mining can help you spot important…
- CourseData Science Projects
- Lesson11 of 33
- Video18 min
- FormatJupyter notebook · 13 code cells
What you'll learn
Data
No separate download needed — the notebook creates or downloads everything it uses.
📓 Full notebook
Download .ipynbGlobal Covid 19 Data Analysis and Visualizations#
- In this lesson, we will explore global Covid 19 data.
- You will learn how to analyze and visualize trends over time.
- Data mining can help you spot important patterns in real world health data.
- Visualizations turn raw numbers into insights anyone can understand.
- By the end, you will have skills to do your own data exploration projects.
- This lesson is beginner friendly with clear, simple steps.
What is Covid 19 Data Mining?#
- Data mining means finding patterns in large data collections.
- Covid 19 datasets record infections, recoveries, and deaths worldwide.
- With the right tools, you can visualize outbreaks, trends, and risks.
- This helps scientists, leaders, and the public understand what is happening.
- We use Python because it is powerful yet beginner friendly.
# Always suppress warnings for a smooth experience
import warnings; warnings.filterwarnings("ignore")
import numpy as np
np.random.seed(42)
# Data setup
import pandas as pd
url = 'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv'
df = pd.read_csv(url)
print(df.shape)
print(df.head(3))
A Quick Look at the Data#
- Each row is a country or region.
- The first columns hold country and location details.
- The remaining columns give confirmed case numbers for each day.
- Our goal is to analyze how cases changed over time and across places.
# See basic info about the table and columns
df.info()
# Check for any missing values
print(df.isnull().sum().head())
Preparing Data for Analysis#
- To visualize trends, we need totals per day for the world.
- We will sum all countries for each date column.
- This creates a global time series to plot.
# Get global daily total confirmed cases
date_cols = df.columns[4:]
global_total = df[date_cols].sum()
print(global_total.head())
# Plot global cases over time
import matplotlib.pyplot as plt
plt.figure(figsize=(10,5))
plt.plot(global_total.index, global_total.values)
plt.title("Worldwide Covid 19 Confirmed Cases Over Time")
plt.xlabel("Date")
plt.ylabel("Total Cases")
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
# Show first 10 days and last 10 days in the global total
print("First 10 days:")
print(global_total.head(10))
print("\nLast 10 days:")
print(global_total.tail(10))
Focusing on Individual Countries#
- Sometimes we want to zoom in on a single country.
- This helps compare trends between places like USA, India, or Italy.
- We will show how to select a specific country and plot its trend.
# Pick a country to explore (for example, India)
india = df[df['Country/Region'] == 'India']
india_total = india[date_cols].sum()
plt.figure(figsize=(10,5))
plt.plot(india_total.index, india_total.values, color='orange')
plt.title("Covid 19 Confirmed Cases in India Over Time")
plt.xlabel("Date")
plt.ylabel("Total Cases")
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
# Let the user choose a country to plot
country_name = input("Type a country name, for example 'Italy': ")
country_data = df[df['Country/Region'] == country_name]
country_total = country_data[date_cols].sum()
plt.figure(figsize=(10,5))
plt.plot(country_total.index, country_total.values, color='green')
plt.title(f"Covid 19 Confirmed Cases in {country_name} Over Time")
plt.xlabel("Date")
plt.ylabel("Total Cases")
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
# Compare top 5 affected countries
top5 = df.groupby('Country/Region')[date_cols[-1]].sum().sort_values(ascending=False).head(5)
print("Top 5 countries by total confirmed cases:")
print(top5)
# Bar chart of top 5 countries
import seaborn as sns
plt.figure(figsize=(8,6))
sns.barplot(x=top5.values, y=top5.index, palette='Reds_r')
plt.xlabel("Total Confirmed Cases")
plt.ylabel("Country")
plt.title("Top 5 Countries by Confirmed Covid 19 Cases")
plt.tight_layout()
plt.show()
Discovering New Daily Cases#
- Total numbers are useful, but it helps to see day by day changes.
- New daily cases show how fast an outbreak is growing or shrinking.
- We can compute daily new cases by subtracting each day's total from the previous day's.
# Calculate new global cases per day
new_cases = global_total.diff().fillna(0).astype(int)
print(new_cases.head(10))
# Plot new global daily cases
plt.figure(figsize=(10,5))
plt.bar(new_cases.index, new_cases.values, color='blue')
plt.title("New Confirmed Covid 19 Cases Each Day (World)")
plt.xlabel("Date")
plt.ylabel("New Cases")
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
Summary and Next Steps#
- We loaded and inspected a real Covid 19 dataset.
- We visualized global and country specific trends.
- We saw how to compare nations and spot changes over time.
- There is much more to explore data mining opens many doors.
- Try changing the country, plotting different time windows, or exploring deaths and recoveries.
- To keep learning, please subscribe and check out other lessons on this channel!
- Practice makes perfect keep experimenting with your own questions.
Found this useful?
All lessons, notebooks and datasets here are free. If they helped you, a coffee keeps new lessons coming.



