Public
Edited
Oct 27
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
wardsAll = ["", "BETHNAL GREEN", "BLACKWALL & CUBITT TOWN", "BOW EAST", "BOW WEST", "BROMLEY NORTH", "BROMLEY SOUTH", "CANARY WHARF", "ISLAND GARDENS", "LANSBURY", "LIMEHOUSE", "MILE END", "POPLAR", "SHADWELL", "SPITALFIELDS & BANGLATOWN", "ST DUNSTAN'S", "ST. KATHARINE'S & WAPPING", "ST PETER'S", "STEPNEY GREEN", "WEAVERS", "WHITECHAPEL"]
Insert cell
collisions = FileAttachment("TH-LTN-collision@3.csv").csv({typed: true})
Insert cell
d3.sum(collisions.filter(d => d.Period === "pre LTN"), d => d["number_of_casualties"])
Insert cell
// collisions_mean = d3.sum(collisions.filter(d => d.Period === "pre LTN"), d => d["number_of_casualties"])
collisions_mean = {
const end = d3.max(collisions.filter(d => d.Period === "pre LTN"), d => d["utcTime"])
const start = d3.min(collisions.filter(d => d.Period === "pre LTN"), d => d["utcTime"])
const nb_year = (end - start) / (365 * 24 * 60 * 60 * 1000)
return d3.sum(collisions.filter(d => d.Period === "pre LTN"), d => d["number_of_casualties"] / nb_year)
}
Insert cell
preLTN = new Date('2020-06-01') // Assumed date LTNs installed
Insert cell
Insert cell
// responseTimesMinusE2 = responseTimes.filter(d => d.Postcode_district !== "E2")
Insert cell
collisions
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more