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": [],
}