A Streamlit dashboard that monitors the real-time status of Transport for London (TFL) tube and DLR lines and highlights contractual incident risk.
This project fetches live service status data from the TFL API, transforms it to flag lines that are not running a "Good Service", and calculates a financial risk value for each incident. The results are displayed in an interactive dashboard.
- Extract - Calls the TFL API endpoint for tube and DLR line statuses.
- Transform - Loops through each line and applies business logic:
- If a line's status is anything other than
"Good Service", it is flagged as a compliance failure ("Yes") and assigned a financial risk of £100. - Lines running normally receive
"No"and£0risk.
- If a line's status is anything other than
- Load (Dashboard) - Displays:
- Top metrics for total assets monitored, contractual incidents, and total financial risk.
- A bar chart showing risk distribution by infrastructure asset.
- A detailed status table for all assets.
Data is cached for 60 seconds using Streamlit cache (@st.cache_data(ttl=60)) to reduce repeated API calls.
Install dependencies with:
pip install -r requirements.txtstreamlit run app.pyThen open the local URL shown in the terminal (typically http://localhost:8501).
The dashboard uses a DataFrame with the following columns:
| Column | Description |
|---|---|
Infrastructure Asset |
Name of the tube or DLR line |
Current Status |
Current service status description |
Compliance Failure |
"Yes" if the line is not running a Good Service, otherwise "No" |
Financial Risk (£) |
Financial risk in £ (£100 per incident, £0 otherwise) |
Live data is sourced from the TFL Unified API:
https://api.tfl.gov.uk/Line/Mode/tube,dlr/Status