The cycle-hire operations lead wants a per-borough utilisation figure — bikes available as a share of docking points — refreshed from every snapshot, because a borough that sits near zero at lunchtime is one the vans are failing. The figure has to come from a script that takes the snapshot file and hands back a table, and the boroughs outside the scheme have to be on it at zero, because the expansion team reads the same table.
Write a script that produces a per-borough utilisation table.
The datasets are mounted where the script runs:
/data/boroughs.geojson — the London boroughs/data/docks.geojson — the 799 docking stations at the snapshotgeopandas, shapely, pyproj, pandas and numpy are available. Assign the finished table to a variable named `result`: a GeoDataFrame with one row per borough, carrying the borough polygon and
namedocks_total — the sum of docks over the stations inside the boroughbikes_total — the sum of bikesutilisation — bikes_total / docks_total, and 0 where there are no docksAssign stations to boroughs by geometry. Do not write a file — the runner reads result.
/data/boroughs.geojson — EPSG:4326; the geometry is in geometry (Polygon).
| column | type | meaning |
|---|---|---|
borough_id | string | Stable identifier of the form LB-01 |
name | string | Borough name; the City of London is included as one unit |
inner_london | boolean | True for the 12 statutory Inner London boroughs and the City |
/data/docks.geojson — EPSG:4326; the geometry is in geometry (Point).
| column | type | meaning |
|---|---|---|
dock_id | string | Station identifier, BP-1 … BP-878 |
name | string | Station name and neighbourhood |
terminal | string | TfL terminal code |
docks | integer | Docking points at the station (docks) |
bikes | integer | Bikes available at the snapshot (bikes) |
empty_docks | integer | Free docking points at the snapshot (docks) |
standard_bikes | integer | Pedal bikes available (bikes) |
ebikes | integer | E-bikes available (bikes) |
temporary | boolean | A temporary event station |
snapshot_at | date | When the counts were read |
Run executes the script in your browser and shows you its output and a preview. Submit executes it again on the server and grades what result holds.
These are where the teaching is. Read them twice.
A scripted per-area ratio from a live feed is the shape of every operations KPI a transport authority refreshes automatically.
Files: /data/boroughs.geojson, /data/docks.geojson · assign result
5 scored, 0 informational
Assigns stations to boroughs with a spatial predicate
17%One row per borough
17%Carries name, docks_total, bikes_total and utilisation
17%Total bikes across all boroughs
25%The highest borough utilisation
25%