Module 14: Real-World Projects
Learning Objectives
By the end of this module, you will be able to:
Apply Pandas skills to realistic, domain-specific datasets
Build complete data analysis pipelines from raw data to insights
Work with diverse data types including sales, climate, health, and geospatial data
Generate reports and visualisations for stakeholder communication
Note
The best way to master Pandas is through hands-on practice with real-world data. This module presents eight projects spanning different domains, each designed to reinforce specific Pandas skills while introducing domain-specific challenges.
Project 1: Sales Dashboard
Domain: Business Analytics
Skills: GroupBy, pivot tables, time series, visualisation
Difficulty: Beginner
Build an interactive sales dashboard that tracks key performance indicators across regions, products, and time periods.
Deliverables
Monthly and quarterly sales summaries with year-over-year comparison
Top-performing products and regions ranked by revenue
Revenue trends with 30-day rolling averages
Pivot tables showing sales by region × product category
Visual dashboard with line charts, bar charts, and summary tables
import pandas as pd
import numpy as np
# Starter code
np.random.seed(42)
dates = pd.date_range("2023-01-01", "2024-12-31", freq="D")
sales_data = pd.DataFrame({
"Date": np.random.choice(dates, 5000),
"Region": np.random.choice(["North", "South", "East", "West"], 5000),
"Product": np.random.choice(["Widget", "Gadget", "Doohickey", "Thingamajig"], 5000),
"Category": np.random.choice(["Electronics", "Hardware", "Software"], 5000),
"Sales": np.round(np.random.uniform(10, 1000, 5000), 2),
"Quantity": np.random.randint(1, 50, 5000),
"Discount": np.random.choice([0, 0.05, 0.1, 0.15, 0.2], 5000, p=[0.6, 0.15, 0.15, 0.05, 0.05]),
})
Data sources: Kaggle Retail Sales, Superstore Dataset
Project 2: COVID-19 Analysis
Domain: Public Health / Epidemiology
Skills: Time series, merging, resampling, visualisation
Difficulty: Beginner–Intermediate
Analyse global COVID-19 trends including confirmed cases, deaths, and vaccination rates across countries and continents.
Deliverables
Country-level trends with confirmed cases, recoveries, and deaths
Comparative analysis across continents using merged datasets
7-day rolling averages to smooth daily fluctuations
Reproduction rate (R₀) estimation from case data
Visualisations showing hotspots, peaks, and vaccination progress
# Starter code
import pandas as pd
# Load data (download from Johns Hopkins CSSE)
# cases_url = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv"
# covid = pd.read_csv(cases_url)
Data sources: Johns Hopkins CSSE, Our World in Data
Project 3: Climate Data Analysis
Domain: Environmental Science / Climatology
Skills: DateTime, resampling, seasonal analysis, visualisation
Difficulty: Intermediate
Analyse historical temperature and precipitation data to identify climate trends, seasonal patterns, and anomalies.
Deliverables
Annual and seasonal temperature trends with linear regression
Precipitation patterns and drought identification
Heatwave detection using rolling percentile thresholds
Comparison of historical normals (1981–2010) vs recent decades
Anomaly detection for extreme weather events
# Starter code
import pandas as pd
import numpy as np
# Generate sample climate data
np.random.seed(42)
dates = pd.date_range("1950-01-01", "2024-12-31", freq="D")
n = len(dates)
climate = pd.DataFrame({
"Temperature": 15 + 10 * np.sin(2 * np.pi * np.arange(n) / 365 - 1.5) + np.random.normal(0, 3, n) + 0.005 * np.arange(n),
"Precipitation": np.random.exponential(5, n),
"Humidity": np.random.uniform(30, 90, n),
}, index=dates)
Data sources: NOAA Climate Data, NASA GISS
Project 4: Agriculture Data Analysis
Domain: Agriculture / Agronomy
Skills: GroupBy, filtering, correlation, visualisation
Difficulty: Intermediate
Analyse crop yield data across regions, seasons, and farming practices to identify factors affecting productivity.
Deliverables
Crop yield comparisons across regions and soil types
Correlation analysis between weather variables and yield
Seasonal planting and harvesting optimisation using historical data
Fertiliser and irrigation impact analysis
Year-over-year production trends with anomaly detection
# Starter code
import pandas as pd
import numpy as np
np.random.seed(42)
n = 1000
agri_data = pd.DataFrame({
"Region": np.random.choice(["Highlands", "Lowlands", "Coastal", "Arid"], n),
"Crop": np.random.choice(["Maize", "Wheat", "Rice", "Soybeans"], n),
"Season": np.random.choice(["Kharif", "Rabi", "Zaid"], n),
"Soil_Type": np.random.choice(["Clay", "Loam", "Sandy", "Silt"], n),
"Yield_tons_per_ha": np.round(np.random.uniform(1.5, 8.0, n), 2),
"Rainfall_mm": np.round(np.random.uniform(200, 1500, n), 0),
"Temperature_C": np.round(np.random.uniform(15, 35, n), 1),
"Fertilizer_kg": np.round(np.random.uniform(50, 300, n), 0),
"Pesticide_use": np.random.choice([0, 1], n, p=[0.6, 0.4]),
})
Data sources: FAO Data, USDA Census of Agriculture
Project 5: Remote Sensing Vegetation Analysis
Domain: Remote Sensing / Environmental Monitoring
Skills: MultiIndex, merging geospatial data, time series, visualisation
Difficulty: Intermediate–Advanced
Analyse satellite-derived vegetation indices (NDVI, EVI) to monitor vegetation health, detect deforestation, and track seasonal cycles.
Deliverables
Time series analysis of NDVI values for selected regions
Seasonal vegetation phenology (start/end of growing season)
Deforestation detection using year-over-year NDVI change
Correlation between vegetation indices and climate variables
Land cover classification using spectral indices
# Starter code
import pandas as pd
import numpy as np
np.random.seed(42)
# Simulate NDVI time series for multiple locations
locations = [f"Site_{i}" for i in range(1, 11)]
dates = pd.date_range("2020-01-01", "2024-12-31", freq="16D") # MODIS frequency
n = len(dates)
data = []
for loc in locations:
# Base NDVI varies by location
base = np.random.uniform(0.2, 0.8)
for i, date in enumerate(dates):
# Add seasonal pattern
seasonal = 0.3 * np.sin(2 * np.pi * i / 23 - 1.5) # ~1 year cycle
noise = np.random.normal(0, 0.05)
ndvi = np.clip(base + seasonal + noise, 0, 1)
data.append({"Location": loc, "Date": date, "NDVI": ndvi})
ndvi_df = pd.DataFrame(data)
Data sources: USGS EarthExplorer, NASA MODIS, Sentinel Hub
Project 6: Water Resources Analysis
Domain: Hydrology / Water Management
Skills: Resampling, rolling windows, time series decomposition, missing data handling
Difficulty: Intermediate
Analyse river flow, reservoir levels, and water quality data to assess water resource availability and trends.
Deliverables
River discharge trends with seasonal decomposition
Reservoir level analysis with drought identification
Water quality parameter trends (pH, turbidity, dissolved oxygen)
Rainfall-runoff correlation analysis
Water scarcity risk assessment using percentile thresholds
# Starter code
import pandas as pd
import numpy as np
np.random.seed(42)
dates = pd.date_range("2010-01-01", "2024-12-31", freq="D")
n = len(dates)
# Simulate daily river flow with seasonal pattern
days = np.arange(n)
flow = (
100 # Base flow
+ 80 * np.sin(2 * np.pi * days / 365 - 0.5) # Seasonal
+ 30 * np.sin(2 * np.pi * days / (365 * 5)) # Multi-year cycle
+ np.random.normal(0, 15, n) # Noise
)
flow = np.maximum(flow, 5) # Minimum flow
water = pd.DataFrame({
"River_Flow_cms": flow,
"Rainfall_mm": np.random.exponential(10, n),
"pH": np.random.normal(7.2, 0.5, n).clip(6, 8.5),
"Turbidity_NTU": np.random.exponential(5, n),
"DO_mg_L": np.random.normal(7.5, 1.0, n).clip(4, 12),
}, index=dates)
Data sources: USGS Water Data, Global Runoff Data Centre
Project 7: Land Cover Change Detection
Domain: Geography / Environmental Change
Skills: MultiIndex, merging, crosstab, visualisation
Difficulty: Advanced
Detect and quantify land cover changes over time using classified satellite imagery and transition matrices.
Deliverables
Land cover transition matrices (change detection matrices)
Net change analysis by cover type (forest loss, urban gain, etc.)
Spatiotemporal change visualisation with stacked bar charts
Deforestation rate calculation with annual change metrics
Hotspot identification for rapid land cover change
# Starter code
import pandas as pd
import numpy as np
np.random.seed(42)
# Simulate land cover classifications for multiple years
land_cover_classes = ["Forest", "Grassland", "Cropland", "Urban", "Water", "Barren"]
years = [2015, 2017, 2019, 2021, 2023]
n_pixels = 10000
# Transition probabilities
def generate_year(base, transition_prob=0.1):
new = base.copy()
mask = np.random.random(n_pixels) < transition_prob
if mask.any():
new[mask] = np.random.choice(land_cover_classes, mask.sum())
return new
base = np.random.choice(land_cover_classes, n_pixels)
data = {"Pixel_ID": range(n_pixels), "2015": base}
for year in years[1:]:
data[str(year)] = generate_year(data[str(years[years.index(year) - 1])])
lc_df = pd.DataFrame(data)
Data sources: ESA CCI Land Cover, USGS Landsat, Copernicus Global Land
Project 8: Population Analysis
Domain: Demography / Social Science
Skills: Data cleaning, merging, groupBy, visualisation
Difficulty: Beginner–Intermediate
Analyse population data across countries, age groups, and time to identify demographic trends and patterns.
Deliverables
Population pyramids for selected countries and years
Urban vs rural population trends over time
Dependency ratio analysis (young + old / working age)
Population growth rate calculation with CAGR
Migration impact analysis using population change components
# Starter code
import pandas as pd
import numpy as np
np.random.seed(42)
# Simulate population data
countries = ["Ethiopia", "Kenya", "Nigeria", "South Africa", "Ghana"]
years = list(range(2000, 2025))
age_groups = ["0–14", "15–24", "25–54", "55–64", "65+"]
data = []
for country in countries:
base_pop = np.random.randint(10, 200, 1)[0] # Millions
for year in years:
growth = np.random.uniform(-0.02, 0.04)
pop = base_pop * (1 + growth) ** (year - 2000)
for age in age_groups:
pct = np.random.dirichlet(np.ones(5))[age_groups.index(age)]
data.append({
"Country": country,
"Year": year,
"Age_Group": age,
"Population_M": round(pop * pct, 2),
"Urban_Pct": np.random.uniform(20, 80),
"Fertility_Rate": round(np.random.uniform(1.5, 6.0, 1)[0], 2),
})
pop_df = pd.DataFrame(data)
Data sources: World Bank Data, UN Population Division, Census Bureau IDB
How to Approach Each Project
For each project, follow this structured workflow:
Data Acquisition — Download or generate the dataset; document its source and structure
Data Loading — Use appropriate Pandas readers (
read_csv,read_excel,read_parquet)Data Cleaning — Handle missing values, fix data types, remove duplicates
Exploratory Analysis — Use
.describe(),.info(),.value_counts(), and basic plotsTransformation — Apply groupBy, pivot tables, resampling, and feature engineering
Visualisation — Create informative charts that answer specific business or research questions
Interpretation — Document findings, draw conclusions, and suggest limitations
Delivery — Package results as a Jupyter notebook, report, or dashboard
Summary
Eight real-world projects covering sales, health, climate, agriculture, remote sensing, water resources, land cover, and population analysis
Each project targets specific Pandas skills at progressive difficulty levels
Follow the structured workflow: load → clean → explore → transform → visualise → interpret → deliver
All projects include starter code and data source references for further exploration