Resumen ejecutivo
Este informe demuestra cómo datos abiertos de accidentes de tránsito pueden convertirse en inteligencia operacional usando Python, SQL Server y análisis progresivo basado en preguntas. El trabajo integró 2,906,173 registros de California Crashes entre 2019 y 2025 en una tabla SQL Server local y luego desarrolló un análisis de severidad, letalidad, peatones e iluminación.
Contenido
- Contexto del análisis
- Validación histórica de carga
- KPI histórico
- Fatality Rate por año
- Frecuencia por tipo de colisión
- Letalidad por tipo de accidente
- Evolución de peatones fallecidos
- Accidentes de peatones y tasa de fatalidad
- Ciudades con mayor riesgo peatonal
- Ciudad + iluminación
- Iluminación a nivel estatal
- Lecciones y narrativa ejecutiva
0. Contexto del análisis
Después de cargar los archivos CCRS de California desde 2019 hasta 2025, el objetivo dejó de ser técnico y pasó a ser analítico: preguntar mejor, validar hipótesis y convertir registros operacionales en inteligencia de negocio.
Fuente: California Crash Reporting System (CCRS), California Open Data Portal.
1. Validación histórica de carga
¿La carga de 2019 a 2025 quedó correctamente distribuida por año?
SELECT
Source_Year,
COUNT(*) AS TotalRows
FROM dbo.Crashes
GROUP BY Source_Year
ORDER BY Source_Year;
| Año | Registros |
|---|---|
| 2019 | 478,189 |
| 2020 | 374,757 |
| 2021 | 422,980 |
| 2022 | 405,249 |
| 2023 | 409,815 |
| 2024 | 416,917 |
| 2025 | 398,266 |
- Los siete años esperados aparecen en la tabla final.
- El total validado por SQL Server es 2,906,173 registros.
- La tabla dbo.Crashes quedó lista para análisis histórico, no solo para pruebas de carga.
La carga quedó validada directamente en SQL Server. Esto confirma que el ETL no solo ejecutó, sino que integró correctamente los años esperados en una tabla histórica única.
2. KPI histórico: accidentes, fallecidos y lesionados
La cantidad de accidentes puede bajar, pero la severidad puede subir. Por eso no basta con contar eventos; hay que medir muertos, lesionados y tasas.
SELECT
Source_Year,
COUNT(*) AS TotalCrashes,
SUM(TRY_CAST(NumberKilled AS INT)) AS TotalKilled,
SUM(TRY_CAST(NumberInjured AS INT)) AS TotalInjured
FROM dbo.Crashes
GROUP BY Source_Year
ORDER BY Source_Year;
| Año | Accidentes | Fallecidos | Lesionados |
|---|---|---|---|
| 2019 | 478,189 | 3,787 | 270,248 |
| 2020 | 374,757 | 4,081 | 205,029 |
| 2021 | 422,980 | 4,590 | 228,359 |
| 2022 | 405,249 | 4,661 | 226,304 |
| 2023 | 409,815 | 4,269 | 230,844 |
| 2024 | 416,917 | 4,030 | 236,847 |
| 2025 | 398,266 | 3,104 | 228,833 |
- 2019 tuvo el mayor volumen de accidentes: 478,189.
- 2020 bajó a 374,757 accidentes, pero subió a 4,081 fallecidos.
- 2022 tuvo el mayor número absoluto de fallecidos: 4,661.
- 2025 redujo fallecidos a 3,104, el valor más bajo del periodo mostrado.
El 2020 muestra una caída fuerte en accidentes frente a 2019, pero las fatalidades suben. Esta diferencia confirma que volumen y severidad son dimensiones distintas. El dato sugiere un cambio de comportamiento vial durante y después del periodo COVID: menos eventos, pero eventos más letales.
3. Fatality Rate por año
¿Los accidentes fueron menos frecuentes pero más letales durante 2020–2022?
SELECT
Source_Year,
COUNT(*) AS TotalCrashes,
SUM(TRY_CAST(NumberKilled AS INT)) AS TotalKilled,
CAST(
SUM(TRY_CAST(NumberKilled AS INT)) * 100.0 /
COUNT(*)
AS DECIMAL(10,4)
) AS FatalityRatePct
FROM dbo.Crashes
GROUP BY Source_Year
ORDER BY Source_Year;
| Año | Accidentes | Fallecidos | Fatality Rate % |
|---|---|---|---|
| 2019 | 478,189 | 3,787 | 0.7919 |
| 2020 | 374,757 | 4,081 | 1.0890 |
| 2021 | 422,980 | 4,590 | 1.0852 |
| 2022 | 405,249 | 4,661 | 1.1502 |
| 2023 | 409,815 | 4,269 | 1.0417 |
| 2024 | 416,917 | 4,030 | 0.9666 |
| 2025 | 398,266 | 3,104 | 0.7794 |
- 2022 fue el peor año por tasa de fatalidad: 1.1502%.
- 2020 tuvo menos accidentes que 2019, pero una tasa mucho más alta.
- 2025 muestra la mejor tasa de la serie: 0.7794%, incluso ligeramente mejor que 2019.
Este query cambia la narrativa. No se trata de decir “hubo menos accidentes”; se trata de entender que algunos años tuvieron menos frecuencia, pero mayor severidad. La tasa normalizada es la métrica que permite ver el riesgo real.
4. Frecuencia por tipo de colisión
¿Cómo evolucionan los tipos de accidente por año?
SELECT
Source_Year,
Collision_Type_Code,
COUNT(*) AS TotalCrashes
FROM dbo.Crashes
GROUP BY
Source_Year,
Collision_Type_Code
ORDER BY
Source_Year,
Collision_Type_Code;
El código C = REAR END se mantiene como el tipo más frecuente en todos los años revisados.
| Año | C = Rear End |
|---|---|
| 2019 | 158,474 |
| 2020 | 104,981 |
| 2021 | 126,485 |
| 2022 | 120,450 |
| 2023 | 120,836 |
- El código C = REAR END domina consistentemente por volumen.
- 2019 tuvo 158,474 REAR END crashes, el mayor volumen observado en la muestra.
- La caída de 2020 también se observa en REAR END, bajando a 104,981.
REAR END domina por frecuencia, pero eso no significa que sea el principal problema de mortalidad. Esta diferencia llevó al siguiente análisis: separar frecuencia de letalidad.
5. Letalidad por tipo de accidente
El accidente más común no necesariamente es el más peligroso.
SELECT
Collision_Type_Code,
COUNT(*) AS TotalCrashes,
SUM(TRY_CAST(NumberKilled AS INT)) AS TotalKilled,
CAST(
SUM(TRY_CAST(NumberKilled AS INT))*100.0 /
COUNT(*)
AS DECIMAL(10,4)
) AS FatalityRatePct
FROM dbo.Crashes
WHERE Collision_Type_Code IS NOT NULL
GROUP BY Collision_Type_Code
ORDER BY FatalityRatePct DESC;
| Code | Tipo | Crashes | Killed | Fatality Rate % |
|---|---|---|---|---|
| G | Vehicle/Pedestrian | 84,550 | 7,212 | 8.5299 |
| F | Overturned | 69,943 | 1,865 | 2.6665 |
| A | Head-On | 134,202 | 3,510 | 2.6155 |
| E | Hit Object | 517,563 | 6,769 | 1.3079 |
| H | Other | 793,460 | 7,033 | 0.8860 |
| D | Broadside | 517,182 | 4,577 | 0.8850 |
| C | Rear End | 872,069 | 2,661 | 0.3051 |
| B | Side Swipe | 617,193 | 1,145 | 0.1855 |
- G = Vehicle/Pedestrian es el tipo más letal: 8.5299%.
- F = Overturned y A = Head-On superan el 2.6% de letalidad.
- C = Rear End tiene el mayor volumen, pero una tasa mucho menor: 0.3051%.
- B = Side Swipe tiene la menor tasa relativa: 0.1855%.
El código G, accidentes vehículo/peatón, es el más letal por gran diferencia. Aunque REAR END es el más frecuente, su letalidad relativa es baja. Esto obliga a separar dashboards de volumen y dashboards de severidad.
6. Evolución de peatones fallecidos
¿Los peatones mejoraron o empeoraron entre 2019 y 2025?
SELECT
Source_Year,
SUM(
CASE
WHEN Collision_Type_Code='G'
THEN TRY_CAST(NumberKilled AS INT)
ELSE 0
END
) AS PedestrianKilled
FROM dbo.Crashes
GROUP BY Source_Year
ORDER BY Source_Year;
| Año | Peatones fallecidos |
|---|---|
| 2019 | 960 |
| 2020 | 963 |
| 2021 | 1,127 |
| 2022 | 1,167 |
| 2023 | 1,107 |
| 2024 | 1,076 |
| 2025 | 812 |
- Las muertes de peatones suben desde 960 en 2019 hasta 1,167 en 2022.
- 2022 es el pico absoluto de peatones fallecidos.
- 2025 baja a 812, una reducción fuerte frente a 2024.
El pico de muertes de peatones ocurre en 2022. La reducción en 2025 es fuerte y abre una pregunta de política pública: ¿qué cambió entre 2022 y 2025?
7. Accidentes de peatones y tasa de fatalidad por año
La mejora de 2025 puede venir por menos accidentes de peatones, menor severidad o ambas cosas.
SELECT
Source_Year,
COUNT(*) AS PedestrianCrashes,
SUM(TRY_CAST(NumberKilled AS INT)) AS PedestrianKilled,
CAST(
SUM(TRY_CAST(NumberKilled AS INT))*100.0 /
COUNT(*)
AS DECIMAL(10,2)
) AS PedestrianFatalityRate
FROM dbo.Crashes
WHERE Collision_Type_Code = 'G'
GROUP BY Source_Year
ORDER BY Source_Year;
| Año | Pedestrian Crashes | Pedestrian Killed | Fatality Rate % |
|---|---|---|---|
| 2019 | 13,881 | 960 | 6.92 |
| 2020 | 10,388 | 963 | 9.27 |
| 2021 | 11,156 | 1,127 | 10.10 |
| 2022 | 11,788 | 1,167 | 9.90 |
| 2023 | 12,470 | 1,107 | 8.88 |
| 2024 | 12,781 | 1,076 | 8.42 |
| 2025 | 12,086 | 812 | 6.72 |
- 2021 fue el peor año por tasa de fatalidad peatonal: 10.10%.
- En 2020 hubo menos accidentes peatonales que en 2019, pero mayor tasa de fatalidad.
- 2025 presenta una mejora notable y cae por debajo del nivel 2019.
La recuperación de 2025 no solo reduce muertes absolutas; también reduce la tasa. Esto sugiere una mejora real de severidad, no solamente un cambio de volumen.
8. Ciudades con mayor tasa de fatalidad peatonal
¿Qué ciudades presentan mayor riesgo relativo en accidentes con peatones, usando un umbral mínimo para evitar ruido extremo?
SELECT TOP 25
City_Name,
COUNT(*) AS PedestrianCrashes,
SUM(TRY_CAST(NumberKilled AS INT)) AS PedestrianKilled,
CAST(
SUM(TRY_CAST(NumberKilled AS INT))*100.0 /
COUNT(*)
AS DECIMAL(10,2)
) AS PedestrianFatalityRate
FROM dbo.Crashes
WHERE Collision_Type_Code = 'G'
GROUP BY City_Name
HAVING COUNT(*) >= 100
ORDER BY PedestrianFatalityRate DESC;
| City | Pedestrian Crashes | Killed | Fatality Rate % |
|---|---|---|---|
| Apple Valley | 105 | 26 | 24.76 |
| Stanton | 141 | 33 | 23.40 |
| Colton | 136 | 30 | 22.06 |
| Fountain Valley | 115 | 25 | 21.74 |
| Victorville | 285 | 58 | 20.35 |
| Hesperia | 155 | 29 | 18.71 |
| Unincorporated | 11,564 | 1,713 | 14.81 |
- Apple Valley lidera por tasa: 24.76%.
- Stanton, Colton y Fountain Valley superan el 21%.
- Unincorporated combina volumen extremo con riesgo alto: 11,564 accidentes peatonales y 1,713 fallecidos.
Algunas ciudades pequeñas muestran tasas muy altas. Unincorporated no lidera por tasa, pero por volumen absoluto es el gran monstruo. Esto requiere dos lentes: tasa para riesgo relativo y volumen para impacto total.
9. Ciudad + iluminación en accidentes peatonales
Las ciudades de mayor riesgo podrían estar asociadas a oscuridad, falta de iluminación o luces no funcionales.
SELECT TOP 30
City_Name,
LightingDescription,
COUNT(*) AS PedestrianCrashes,
SUM(TRY_CAST(NumberKilled AS INT)) AS PedestrianKilled,
CAST(
SUM(TRY_CAST(NumberKilled AS INT)) * 100.0 / COUNT(*)
AS DECIMAL(10,2)
) AS FatalityRate
FROM dbo.Crashes
WHERE Collision_Type_Code = 'G'
GROUP BY City_Name, LightingDescription
HAVING COUNT(*) >= 50
ORDER BY FatalityRate DESC;
| City | Lighting | Crashes | Killed | Fatality Rate % |
|---|---|---|---|---|
| San Jose | DARK-NO STREET LIGHTS | 73 | 28 | 38.36 |
| Unincorporated | DARK-STREET LIGHTS NOT FUNCTIONING | 61 | 23 | 37.70 |
| Fresno | DARK-NO STREET LIGHTS | 96 | 36 | 37.50 |
| Los Angeles | DARK-STREET LIGHTS NOT FUNCTIONING | 160 | 58 | 36.25 |
| San Diego | DARK-NO STREET LIGHTS | 248 | 82 | 33.06 |
| Unincorporated | DARK-NO STREET LIGHTS | 2,747 | 870 | 31.67 |
- Los primeros registros están dominados por DARK-NO STREET LIGHTS y DARK-STREET LIGHTS NOT FUNCTIONING.
- San Jose / DARK-NO STREET LIGHTS muestra 38.36%.
- Los Angeles / DARK-STREET LIGHTS NOT FUNCTIONING muestra 36.25%.
- Unincorporated / DARK-NO STREET LIGHTS combina gran volumen: 2,747 casos y 870 fallecidos.
Los primeros lugares están dominados por condiciones oscuras: sin alumbrado o con alumbrado no funcional. Esto transforma el análisis en una hipótesis operacional clara: la iluminación puede estar asociada de manera fuerte con la severidad peatonal.
10. Iluminación y fatalidad peatonal en todo California
Quitando el ruido de ciudad, ¿qué relación aparece entre iluminación y tasa de fatalidad peatonal a nivel estatal?
SELECT
LightingDescription,
COUNT(*) AS PedestrianCrashes,
SUM(TRY_CAST(NumberKilled AS INT)) AS PedestrianKilled,
CAST(
SUM(TRY_CAST(NumberKilled AS INT))*100.0 /
COUNT(*)
AS DECIMAL(10,2)
) AS FatalityRate
FROM dbo.Crashes
WHERE Collision_Type_Code='G'
GROUP BY LightingDescription
ORDER BY FatalityRate DESC;
| Lighting Condition | Pedestrian Crashes | Pedestrian Killed | Fatality Rate % |
|---|---|---|---|
| DARK-STREET LIGHTS NOT FUNCTIONING | 475 | 165 | 34.74 |
| DARK-NO STREET LIGHTS | 6,504 | 1,920 | 29.52 |
| DARK-STREET LIGHTS | 29,531 | 3,664 | 12.41 |
| DUSK-DAWN | 3,644 | 307 | 8.42 |
| DAYLIGHT | 44,066 | 1,144 | 2.60 |
La oscuridad mata. En la muestra histórica 2019–2025, los accidentes peatonales en condiciones DARK-NO STREET LIGHTS tienen una tasa de fatalidad de 29.52%, frente a 2.60% en DAYLIGHT.
Este es el hallazgo más fuerte del viaje analítico. La disponibilidad y funcionamiento de la iluminación no aparece como un simple atributo descriptivo; aparece como una variable crítica asociada a la severidad de accidentes con peatones.
11. Lecciones analíticas del proceso
- Volumen no es riesgo: REAR END domina por frecuencia, pero no por letalidad.
- Normalizar cambia la historia: Fatality Rate revela lo que el conteo bruto oculta.
- Los códigos importan: el texto PEDESTRAIN tenía error ortográfico; el código G fue más confiable.
- La granularidad importa: Año → tipo → peatón → ciudad → iluminación.
- La IA como partner acelera: cada respuesta del dato generó una pregunta mejor.
12. Narrativa ejecutiva final
El análisis histórico de California Crashes 2019–2025 muestra una reducción fuerte de accidentes en 2020, pero con aumento de letalidad. La severidad alcanza su punto más alto alrededor de 2021–2022 y mejora de forma sostenida hacia 2025.
Los accidentes con peatones representan el tipo más letal por tasa relativa. Dentro de ellos, la iluminación emerge como un factor crítico: los accidentes en oscuridad, especialmente sin alumbrado o con luces no funcionales, presentan tasas de fatalidad dramáticamente superiores a los accidentes en daylight.
Conclusión: este no fue solamente un ejercicio de Python o SQL Server. Fue un caso completo de transformación de datos abiertos en inteligencia operacional, usando preguntas progresivas, business rules, normalización de métricas y análisis valorativo.
PythonSQL ServerOpen DataTraffic SafetyPedestrian RiskLighting AnalysisBusiness Intelligence
Executive Summary
This report demonstrates how public traffic crash data can be transformed into operational intelligence using Python, SQL Server, and progressive question-driven analysis. The work integrated 2,906,173 records from California Crashes between 2019 and 2025 into a local SQL Server table and then developed severity, fatality, pedestrian, and lighting-condition analysis.
Contents
- Analysis context
- Historical load validation
- Historical KPI
- Fatality Rate by year
- Frequency by collision type
- Fatality by collision type
- Pedestrian fatalities over time
- Pedestrian crashes and fatality rate
- Cities with higher pedestrian fatality rates
- City + lighting
- Lighting statewide
- Lessons and executive narrative
0. Analysis Context
After loading the California CCRS files from 2019 through 2025, the objective moved from a technical exercise to an analytical one: asking better questions, testing hypotheses, and converting operational records into business intelligence.
Source: California Crash Reporting System (CCRS), California Open Data Portal.
1. Historical Load Validation
Was the 2019–2025 load correctly distributed by year?
SELECT
Source_Year,
COUNT(*) AS TotalRows
FROM dbo.Crashes
GROUP BY Source_Year
ORDER BY Source_Year;| Year | Records |
|---|---|
| 2019 | 478,189 |
| 2020 | 374,757 |
| 2021 | 422,980 |
| 2022 | 405,249 |
| 2023 | 409,815 |
| 2024 | 416,917 |
| 2025 | 398,266 |
- All seven expected years are present in the final table.
- The SQL Server validated total is 2,906,173 records.
- dbo.Crashes became ready for historical analysis, not just load testing.
The load was validated directly in SQL Server. This confirms the ETL did not merely run; it correctly integrated the expected years into one historical table.
2. Historical KPI: Crashes, Fatalities, and Injuries
Crash counts can decrease while severity increases. Therefore, counting events is not enough; fatalities, injuries, and rates must also be measured.
SELECT
Source_Year,
COUNT(*) AS TotalCrashes,
SUM(TRY_CAST(NumberKilled AS INT)) AS TotalKilled,
SUM(TRY_CAST(NumberInjured AS INT)) AS TotalInjured
FROM dbo.Crashes
GROUP BY Source_Year
ORDER BY Source_Year;| Year | Crashes | Fatalities | Injuries |
|---|---|---|---|
| 2019 | 478,189 | 3,787 | 270,248 |
| 2020 | 374,757 | 4,081 | 205,029 |
| 2021 | 422,980 | 4,590 | 228,359 |
| 2022 | 405,249 | 4,661 | 226,304 |
| 2023 | 409,815 | 4,269 | 230,844 |
| 2024 | 416,917 | 4,030 | 236,847 |
| 2025 | 398,266 | 3,104 | 228,833 |
- 2019 had the highest crash volume: 478,189.
- 2020 dropped to 374,757 crashes but increased to 4,081 fatalities.
- 2022 had the highest absolute fatalities: 4,661.
- 2025 reduced fatalities to 3,104, the lowest value in the period shown.
2020 shows a strong decrease in crashes compared with 2019, but fatalities increased. This confirms that volume and severity are different dimensions. The data suggests a shift in road behavior during and after the COVID period: fewer events, but more lethal events.
3. Fatality Rate by Year
Were crashes less frequent but more lethal during 2020–2022?
SELECT
Source_Year,
COUNT(*) AS TotalCrashes,
SUM(TRY_CAST(NumberKilled AS INT)) AS TotalKilled,
CAST(
SUM(TRY_CAST(NumberKilled AS INT)) * 100.0 /
COUNT(*)
AS DECIMAL(10,4)
) AS FatalityRatePct
FROM dbo.Crashes
GROUP BY Source_Year
ORDER BY Source_Year;| Year | Crashes | Fatalities | Fatality Rate % |
|---|---|---|---|
| 2019 | 478,189 | 3,787 | 0.7919 |
| 2020 | 374,757 | 4,081 | 1.0890 |
| 2021 | 422,980 | 4,590 | 1.0852 |
| 2022 | 405,249 | 4,661 | 1.1502 |
| 2023 | 409,815 | 4,269 | 1.0417 |
| 2024 | 416,917 | 4,030 | 0.9666 |
| 2025 | 398,266 | 3,104 | 0.7794 |
- 2022 was the worst year by fatality rate: 1.1502%.
- 2020 had fewer crashes than 2019 but a much higher fatality rate.
- 2025 shows the best rate in the series: 0.7794%, slightly better than 2019.
This query changes the narrative. It is not enough to say “there were fewer crashes”; some years had lower frequency but higher severity. The normalized rate is the metric that reveals real risk.
4. Frequency by Collision Type
How do collision types evolve by year?
SELECT
Source_Year,
Collision_Type_Code,
COUNT(*) AS TotalCrashes
FROM dbo.Crashes
GROUP BY
Source_Year,
Collision_Type_Code
ORDER BY
Source_Year,
Collision_Type_Code;Code C = REAR END remains the most frequent collision type across the reviewed years.
| Year | C = Rear End |
|---|---|
| 2019 | 158,474 |
| 2020 | 104,981 |
| 2021 | 126,485 |
| 2022 | 120,450 |
| 2023 | 120,836 |
- C = REAR END consistently dominates by volume.
- 2019 had 158,474 rear-end crashes, the highest observed volume in the sample.
- The 2020 drop is also visible in rear-end crashes, decreasing to 104,981.
Rear-end crashes dominate by frequency, but that does not mean they are the main fatality problem. This distinction led to the next analysis: separating frequency from lethality.
5. Fatality by Collision Type
The most common collision type is not necessarily the most dangerous.
SELECT
Collision_Type_Code,
COUNT(*) AS TotalCrashes,
SUM(TRY_CAST(NumberKilled AS INT)) AS TotalKilled,
CAST(
SUM(TRY_CAST(NumberKilled AS INT))*100.0 /
COUNT(*)
AS DECIMAL(10,4)
) AS FatalityRatePct
FROM dbo.Crashes
WHERE Collision_Type_Code IS NOT NULL
GROUP BY Collision_Type_Code
ORDER BY FatalityRatePct DESC;| Code | Type | Crashes | Fatalities | Fatality Rate % |
|---|---|---|---|---|
| G | Vehicle/Pedestrian | 84,550 | 7,212 | 8.5299 |
| F | Overturned | 69,943 | 1,865 | 2.6665 |
| A | Head-On | 134,202 | 3,510 | 2.6155 |
| E | Hit Object | 517,563 | 6,769 | 1.3079 |
| H | Other | 793,460 | 7,033 | 0.8860 |
| D | Broadside | 517,182 | 4,577 | 0.8850 |
| C | Rear End | 872,069 | 2,661 | 0.3051 |
| B | Side Swipe | 617,193 | 1,145 | 0.1855 |
- G = Vehicle/Pedestrian is the most lethal type: 8.5299%.
- F = Overturned and A = Head-On exceed a 2.6% fatality rate.
- C = Rear End has the highest volume but a much lower fatality rate: 0.3051%.
- B = Side Swipe has the lowest relative rate: 0.1855%.
Code G, vehicle/pedestrian crashes, is the most lethal by a wide margin. Although rear-end crashes are the most frequent, their relative lethality is low. This forces a separation between volume dashboards and severity dashboards.
6. Pedestrian Fatalities Over Time
Did pedestrian safety improve or worsen between 2019 and 2025?
SELECT
Source_Year,
SUM(
CASE
WHEN Collision_Type_Code='G'
THEN TRY_CAST(NumberKilled AS INT)
ELSE 0
END
) AS PedestrianKilled
FROM dbo.Crashes
GROUP BY Source_Year
ORDER BY Source_Year;| Year | Pedestrian Fatalities |
|---|---|
| 2019 | 960 |
| 2020 | 963 |
| 2021 | 1,127 |
| 2022 | 1,167 |
| 2023 | 1,107 |
| 2024 | 1,076 |
| 2025 | 812 |
- Pedestrian fatalities increased from 960 in 2019 to 1,167 in 2022.
- 2022 was the absolute peak for pedestrian fatalities.
- 2025 dropped to 812, a strong reduction compared with 2024.
The peak for pedestrian fatalities occurred in 2022. The strong reduction in 2025 opens a public-policy question: what changed between 2022 and 2025?
7. Pedestrian Crashes and Fatality Rate by Year
The 2025 improvement may come from fewer pedestrian crashes, lower severity, or both.
SELECT
Source_Year,
COUNT(*) AS PedestrianCrashes,
SUM(TRY_CAST(NumberKilled AS INT)) AS PedestrianKilled,
CAST(
SUM(TRY_CAST(NumberKilled AS INT))*100.0 /
COUNT(*)
AS DECIMAL(10,2)
) AS PedestrianFatalityRate
FROM dbo.Crashes
WHERE Collision_Type_Code = 'G'
GROUP BY Source_Year
ORDER BY Source_Year;| Year | Pedestrian Crashes | Pedestrian Fatalities | Fatality Rate % |
|---|---|---|---|
| 2019 | 13,881 | 960 | 6.92 |
| 2020 | 10,388 | 963 | 9.27 |
| 2021 | 11,156 | 1,127 | 10.10 |
| 2022 | 11,788 | 1,167 | 9.90 |
| 2023 | 12,470 | 1,107 | 8.88 |
| 2024 | 12,781 | 1,076 | 8.42 |
| 2025 | 12,086 | 812 | 6.72 |
- 2021 was the worst year by pedestrian fatality rate: 10.10%.
- In 2020 there were fewer pedestrian crashes than in 2019, but the fatality rate increased.
- 2025 shows a notable improvement and falls below the 2019 level.
The 2025 recovery reduces not only absolute fatalities, but also the fatality rate. This suggests a real improvement in severity, not merely a volume change.
8. Cities with Higher Pedestrian Fatality Rates
Which cities show higher relative risk in pedestrian crashes, using a minimum threshold to reduce extreme noise?
SELECT TOP 25
City_Name,
COUNT(*) AS PedestrianCrashes,
SUM(TRY_CAST(NumberKilled AS INT)) AS PedestrianKilled,
CAST(
SUM(TRY_CAST(NumberKilled AS INT))*100.0 /
COUNT(*)
AS DECIMAL(10,2)
) AS PedestrianFatalityRate
FROM dbo.Crashes
WHERE Collision_Type_Code = 'G'
GROUP BY City_Name
HAVING COUNT(*) >= 100
ORDER BY PedestrianFatalityRate DESC;| City | Pedestrian Crashes | Fatalities | Fatality Rate % |
|---|---|---|---|
| Apple Valley | 105 | 26 | 24.76 |
| Stanton | 141 | 33 | 23.40 |
| Colton | 136 | 30 | 22.06 |
| Fountain Valley | 115 | 25 | 21.74 |
| Victorville | 285 | 58 | 20.35 |
| Hesperia | 155 | 29 | 18.71 |
| Unincorporated | 11,564 | 1,713 | 14.81 |
- Apple Valley leads by rate: 24.76%.
- Stanton, Colton, and Fountain Valley exceed 21%.
- Unincorporated combines extreme volume with high risk: 11,564 pedestrian crashes and 1,713 fatalities.
Some smaller cities show very high rates. Unincorporated does not lead by rate, but by absolute volume it is the major problem. This requires two lenses: rate for relative risk and volume for total impact.
9. City + Lighting in Pedestrian Crashes
The highest-risk cities may be associated with darkness, lack of street lighting, or non-functioning lights.
SELECT TOP 30
City_Name,
LightingDescription,
COUNT(*) AS PedestrianCrashes,
SUM(TRY_CAST(NumberKilled AS INT)) AS PedestrianKilled,
CAST(
SUM(TRY_CAST(NumberKilled AS INT)) * 100.0 / COUNT(*)
AS DECIMAL(10,2)
) AS FatalityRate
FROM dbo.Crashes
WHERE Collision_Type_Code = 'G'
GROUP BY City_Name, LightingDescription
HAVING COUNT(*) >= 50
ORDER BY FatalityRate DESC;| City | Lighting | Crashes | Fatalities | Fatality Rate % |
|---|---|---|---|---|
| San Jose | DARK-NO STREET LIGHTS | 73 | 28 | 38.36 |
| Unincorporated | DARK-STREET LIGHTS NOT FUNCTIONING | 61 | 23 | 37.70 |
| Fresno | DARK-NO STREET LIGHTS | 96 | 36 | 37.50 |
| Los Angeles | DARK-STREET LIGHTS NOT FUNCTIONING | 160 | 58 | 36.25 |
| San Diego | DARK-NO STREET LIGHTS | 248 | 82 | 33.06 |
| Unincorporated | DARK-NO STREET LIGHTS | 2,747 | 870 | 31.67 |
- The top results are dominated by DARK-NO STREET LIGHTS and DARK-STREET LIGHTS NOT FUNCTIONING.
- San Jose / DARK-NO STREET LIGHTS shows 38.36%.
- Los Angeles / DARK-STREET LIGHTS NOT FUNCTIONING shows 36.25%.
- Unincorporated / DARK-NO STREET LIGHTS combines large volume: 2,747 cases and 870 fatalities.
The leading rows are dominated by dark conditions: no lighting or non-functioning lighting. This turns the analysis into a clear operational hypothesis: lighting may be strongly associated with pedestrian-crash severity.
10. Lighting and Pedestrian Fatality Across California
Removing city-level noise, what relationship appears between lighting and statewide pedestrian fatality rate?
SELECT
LightingDescription,
COUNT(*) AS PedestrianCrashes,
SUM(TRY_CAST(NumberKilled AS INT)) AS PedestrianKilled,
CAST(
SUM(TRY_CAST(NumberKilled AS INT))*100.0 /
COUNT(*)
AS DECIMAL(10,2)
) AS FatalityRate
FROM dbo.Crashes
WHERE Collision_Type_Code='G'
GROUP BY LightingDescription
ORDER BY FatalityRate DESC;| Lighting Condition | Pedestrian Crashes | Pedestrian Fatalities | Fatality Rate % |
|---|---|---|---|
| DARK-STREET LIGHTS NOT FUNCTIONING | 475 | 165 | 34.74 |
| DARK-NO STREET LIGHTS | 6,504 | 1,920 | 29.52 |
| DARK-STREET LIGHTS | 29,531 | 3,664 | 12.41 |
| DUSK-DAWN | 3,644 | 307 | 8.42 |
| DAYLIGHT | 44,066 | 1,144 | 2.60 |
Darkness kills. In the 2019–2025 historical sample, pedestrian crashes under DARK-NO STREET LIGHTS conditions have a fatality rate of 29.52%, compared with 2.60% in DAYLIGHT.
This is the strongest finding of the analytical journey. Lighting availability and functionality do not appear as a simple descriptive attribute; they appear as a critical variable associated with the severity of pedestrian crashes.
11. Analytical Lessons
- Volume is not risk: rear-end crashes dominate by frequency, but not by lethality.
- Normalization changes the story: fatality rate reveals what raw counts hide.
- Codes matter: the text PEDESTRAIN contained a spelling issue; code G was more reliable.
- Granularity matters: year → type → pedestrian → city → lighting.
- AI as a partner accelerates the process: every data answer generated a better question.
12. Final Executive Narrative
The historical analysis of California Crashes 2019–2025 shows a sharp decrease in crashes in 2020, but an increase in lethality. Severity reaches its highest point around 2021–2022 and then improves steadily toward 2025.
Pedestrian crashes represent the most lethal crash type by relative rate. Within that segment, lighting emerges as a critical factor: crashes in darkness, especially without street lights or with non-functioning street lights, show dramatically higher fatality rates than daylight crashes.
Conclusion: this was not only a Python or SQL Server exercise. It was a complete case of transforming open data into operational intelligence using progressive questions, business rules, metric normalization, and professional analytical assessment.
PythonSQL ServerOpen DataTraffic SafetyPedestrian RiskLighting AnalysisBusiness Intelligence