Module 2 · Section 12 of 12
Mini-Project 2: Sector Energy Demand Summary Report
Objective: Load the sector electricity-demand dataset, clean it, and produce a summary table showing peak demand by sector and by year - formatted as an engineering report table.
Brief
Using the sector_demand DataFrame built in Lesson 2.7 (sector, year, month,
avg_demand_kw), produce a clean summary table showing peak monthly demand per sector
per year, sorted by sector then year, values rounded to one decimal place and columns
clearly labeled for a non-technical reader.
Starter Code
# --- Rebuild sector_demand so this cell runs standalone ---
# (identical to the generator in Lesson 2.7)
np.random.seed(7)
sectors = ["Chemical", "Semiconductor", "Data Center", "Manufacturing", "Logistics"]
years = [2021, 2022, 2023]
months = range(1, 13)
sector_base = {"Chemical": 2600, "Semiconductor": 4200, "Data Center": 5200,
"Manufacturing": 3100, "Logistics": 1400}
demand_rows = []
for sector in sectors:
base = sector_base[sector]
for year in years:
growth = 1 + 0.04 * (year - 2021)
for month in months:
seasonal = 1.15 if month in (4, 5, 6) else (0.92 if month in (12, 1) else 1.0)
demand_kw = base * growth * seasonal * (1 + np.random.normal(0, 0.03))
demand_rows.append((sector, year, month, round(demand_kw, 1)))
sector_demand = pd.DataFrame(demand_rows, columns=["sector", "year", "month", "avg_demand_kw"])
# --- Starter summary table: peak monthly demand per (sector, year) ---
peak_summary = (
sector_demand
.groupby(["sector", "year"])["avg_demand_kw"] # one group per sector-year
.max() # highest single month in each group
.reset_index() # sector, year back to columns
.rename(columns={"avg_demand_kw": "peak_demand_kw"})
.sort_values(["sector", "year"]) # tidy ordering for a report
)
peak_summary["peak_demand_kw"] = peak_summary["peak_demand_kw"].round(1)
peak_summary
Expected shape: 5 sectors x 3 years = 15 rows, 3 columns (sector, year,
peak_demand_kw).
Deliverable Checklist
-
sector_demandis inspected for missing values and duplicates before summarizing (even though this synthetic version is clean, show the check) - Peak demand is correctly computed per sector and year (not collapsed across years)
- Table is sorted logically (by sector, then year) and values rounded for presentation
- A pivot-table version (
sectorxyear) is also produced for year-over-year comparison - A short written note (2-3 sentences) identifying which sector shows the fastest-growing peak demand
Grading Rubric
| Criterion | Points |
|---|---|
| Data inspected for quality before summarizing | 15 |
| Correct groupby/aggregation logic | 35 |
| Table formatted clearly (sorted, rounded, labeled) | 25 |
| Pivot-table comparison view included | 10 |
| Written interpretation | 15 |
| Total | 100 |
# Your Mini-Project 2 submission
22 / 63 sections · Course home · Join the coaching cohort