Including all schools in England
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 58s

This commit is contained in:
Tudor Sitaru
2026-01-06 16:17:00 +00:00
parent 6fb9b94602
commit 0ea4720ac1
3 changed files with 19 additions and 17 deletions

View File

@@ -15,12 +15,7 @@ from typing import Optional
import os
import re
# Local Authority codes for Wandsworth and Merton
LA_CODES = {
212: "Wandsworth",
315: "Merton"
}
ALLOWED_LA_CODES = list(LA_CODES.keys())
# No longer filtering by specific LA codes - load all available schools
app = FastAPI(
title="SchoolCompare API",
@@ -128,21 +123,22 @@ def load_school_data() -> pd.DataFrame:
print(f"Loading data from {ks2_file}")
df = pd.read_csv(ks2_file, low_memory=False)
# Filter to Wandsworth (212) and Merton (315)
# Handle both string and integer columns
if df['LEA'].dtype == 'object':
if 'LEA' in df.columns and df['LEA'].dtype == 'object':
df['LEA'] = pd.to_numeric(df['LEA'], errors='coerce')
if df['URN'].dtype == 'object':
if 'URN' in df.columns and df['URN'].dtype == 'object':
df['URN'] = pd.to_numeric(df['URN'], errors='coerce')
df = df[df['LEA'].isin(ALLOWED_LA_CODES)]
# Filter to schools only (RECTYPE == 1 means school level data)
if 'RECTYPE' in df.columns:
df = df[df['RECTYPE'] == 1]
# Add year and local authority name
# Add year and local authority name from LANAME column
df['year'] = year
df['local_authority'] = df['LEA'].map(LA_CODES)
if 'LANAME' in df.columns:
df['local_authority'] = df['LANAME']
elif 'LEA' in df.columns:
df['local_authority'] = df['LEA'].astype(str)
# Standardize column names for our API
df = df.rename(columns={
@@ -380,7 +376,7 @@ async def get_filter_options():
if df.empty:
return {
"local_authorities": ["Wandsworth", "Merton"],
"local_authorities": [],
"school_types": [],
"years": [],
}

View File

@@ -78,6 +78,14 @@ async function loadFilters() {
const data = await fetchAPI('/api/filters');
if (!data) return;
// Populate local authority filter
data.local_authorities.forEach(la => {
const option = document.createElement('option');
option.value = la;
option.textContent = la;
elements.localAuthorityFilter.appendChild(option);
});
// Populate school type filter
data.school_types.forEach(type => {
const option = document.createElement('option');

View File

@@ -41,7 +41,7 @@
<section id="dashboard-view" class="view active">
<div class="hero">
<h1 class="hero-title">Compare Primary School Performance</h1>
<p class="hero-subtitle">Explore and compare KS2 results across Wandsworth & Merton primary schools</p>
<p class="hero-subtitle">Explore and compare KS2 results across England's primary schools</p>
</div>
<div class="search-section">
@@ -57,8 +57,6 @@
<div class="filter-row">
<select id="local-authority-filter" class="filter-select">
<option value="">All Areas</option>
<option value="Wandsworth">Wandsworth</option>
<option value="Merton">Merton</option>
</select>
<select id="type-filter" class="filter-select">
<option value="">All School Types</option>
@@ -252,7 +250,7 @@
<footer class="footer">
<p>Data source: <a href="https://www.compare-school-performance.service.gov.uk/download-data" target="_blank">UK Government - Compare School Performance</a></p>
<p class="footer-note">Primary school (KS2) data for Wandsworth and Merton. Data from 2019-2020, 2020-2021, 2021-2022 unavailable due to COVID-19 disruption.</p>
<p class="footer-note">Primary school (KS2) data for England. Data from 2019-2020, 2020-2021, 2021-2022 unavailable due to COVID-19 disruption.</p>
</footer>
<script src="/static/app.js"></script>