DOI: 10.5281/zenodo.17018859
title: Fatal traffic accidents in the city of Madrid during 2024 (Dataset Publication Tutorial)

description: Dataset Summary

This dataset contains fatal traffic accidents in the city of Madrid during 2024. It is derived from the original dataset published by the City Council of Madrid, selecting only those accidents in which the accident resulted in the death of the person involved.

The motivation behind this dataset is to facilitate the analysis of black spots (high-risk accident areas) in Madrid and to contribute to reducing road fatalities.

This resource is also part of a tutorial designed to learn how to publish an open dataset, following best practices for documentation, metadata, and reproducibility. It was created by Ibai Guillén-Pacho and supported by the Predoctoral Grant (PIPF-2022/COM-25947) of the Consejería de Educación, Ciencia y Universidades de la Comunidad de Madrid, Spain.

Changelog

The versions correspond to:



v1.2: corrects a mistake in the columns of dataset v1.1.

v1.1: is the dataset corresponding to the mortality dataset.

v1.0: is  the original dataset of accident rate, which was uploaded by error.


How to Use

The tutorial materials explaining the dataset publication workflow are available at the following repository.

The dataset is distributed as a CSV file with semicolon (;) as the field separator. It can be processed with any software that supports CSV format, such as spreadsheet applications (Excel, LibreOffice, Google Sheets) or programming environments (Python, R, etc.).

# Python Example:

import pandas as pd

# Load the dataset (semicolon-delimited CSV)
df = pd.read_csv("2024_Accidentalidad.csv", delimiter=";")

# Inspect the first records
print(df.head())

 

Dataset Details

This section provides a detailed description of the dataset, including its structure, the collection process, the transformations applied, and the maintenance policy. 

Data Structure

The dataset structure is specified in the original dataset documentation. However, we include here a translated version of the original documentation to facilitate a better understanding of the dataset content. In addition, we have added the field original_row_index, which preserves the row index from the original dataset, allowing users to trace each filtered record back to its source.

IMPORTANT: The file includes one record per person involved in the accident (drivers, passengers, pedestrians, witnesses, etc.).




Nº
Column Name
Description
Expected Values


0
original_row_index
Index of the row in the original dataset, useful to trace records back
Number


1
num_expediente
AAAASNNNNNN, where: • AAAA = accident year • S = accident record
Text


2
fecha
Date in format dd/mm/yyyy
Date


3
hora
Time expressed in 1-hour ranges
Time


4
localizacion
Street 1 – Street 2 (intersection) or a single street  
Text


5
numero
Street number, when applicable    
Number


6
cod_distrito
District code
Number


7
distrito
District name
Text


8
tipo_accidente*
Type of accident (see typology below)
Text


9
estado_meteorologico
Weather conditions description
Text


10
tipo_vehiculo
Type of vehicle involved
Text


11
tipo_persona
Type of person involved  
Text


12
rango_edad
Age range of affected person  
Text


13
sexo
Gender: male, female, or not assigned
Text


14
cod_lesividad*
Severity code (see typology below)
Number


15
lesividad
Description of severity    
Text


16
coordenada_x_utm
X coordinate (UTM projection)  
Number


17
coordenada_y_utm
Y coordinate (UTM projection)
Number


18
positiva_alcohol
Alcohol test result: N (No) or S (Yes)
N / S


19
positiva_droga
Drug test result: NULL or 1
NULL / 1  




TYPES OF ACCIDENTS



Double collision: Traffic accident involving two moving vehicles (head-on, head-side, or side collision).

Multiple collision: Traffic accident involving more than two moving vehicles.

Rear-end collision: Accident occurring when a moving or stopped vehicle (due to traffic conditions) is struck from behind by another vehicle.

Collision with obstacle or road element: Accident occurring between a moving vehicle with a driver and a stationary object occupying the roadway or its surroundings (e.g., parked vehicle, tree, lamppost).

Pedestrian run-over: Accident involving a vehicle and a pedestrian occupying the roadway or walking on sidewalks, crossings, or other areas of the public road not intended for vehicle traffic.

Rollover: Accident involving a vehicle with more than two wheels that, for some reason, loses tire contact with the road and ends up on its side or roof.

Fall: Includes all falls related to traffic circumstances (motorcycle, moped, bicycle, bus passenger, etc.).

Other causes: Includes accidents such as animal run-over, cliff fall, running off the road, and others.


SEVERITY



01: Emergency care without subsequent hospitalization – Minor

02: Hospitalization ≤ 24 hours – Minor

03: Hospitalization > 24 hours – Serious

04: Deceased within 24 hours – Fatal

05: Outpatient medical care afterwards – Minor

06: Immediate medical care in a health center or mutual insurance – Minor

07: Medical care only at the accident site – Minor

14: No medical assistance

77: Unknown

Blank: No medical assistance


Data Collection

The dataset is derived from the official 2024 traffic accident records published by the City Council of Madrid.

Data Processing

From the original dataset, we extracted only the records corresponding to fatal accidents, defined as those in which the variable lesividad has the code 04. The transformed dataset is stored in CSV format, preserving the same structure and columns as the original file, but containing only a reduced subset of cases that meet this criterion. The scripts employed for this processing are available in the repository.

Data Maintenance

The original dataset is maintained and periodically updated by the City Council of Madrid. In contrast, the transformed dataset presented here is designed for tutorial purposes, maintained by the associated teaching team. No further updates are planned beyond potential revisions for new versions of the tutorial. Users interested in updated traffic accident data should always refer to the City of Madrid Open Data Portal.

License

The dataset is distributed under the license terms of the City of Madrid Open Data Portal.

The tutorial materials (including documentation, code, and instructions provided in the GitHub repository) are distributed under the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) license.

Citation

Original dataset: Ayuntamiento de Madrid. Accidentes de tráfico en la ciudad de Madrid (2024). Portal de Datos Abiertos. https://datos.madrid.es/portal/site/egob

Transformed dataset: Guillén-Pacho I. (2025). Fatal Traffic Accidents in Madrid 2024. Zenodo. https://doi.org/10.5281/zenodo.17018859

Funding

This work is supported by the Predoctoral Grant (PIPF-2022/COM-25947) of the Consejería de Educación, Ciencia y Universidades de la Comunidad de Madrid, Spain.