Public
Edited
Apr 24, 2023
Insert cell
Insert cell
Insert cell
rental = rental2018.concat(rental2020).concat(rental2021)
Insert cell
Insert cell
ownership2021 = aggregate(housing2021, 'ownership', 'Income-Restricted Ownership', '2021')
Insert cell
rental2021 = aggregate(housing2021, 'rental', 'Income-Restricted Rental', '2021')
Insert cell
income-restricted-inventory-2021.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
ownership2020 = aggregate(housing2020, 'ownership', 'Income- Restricted Ownership', '2020')
Insert cell
rental2020 = aggregate(housing2020, 'rental', 'Income- Restricted Rental', '2020')
Insert cell
income-restricted-inventory-2020.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
rental2018 = aggregate(housing2018, 'rental', 'Income- Restricted Rental', '2018')
Insert cell
ownership2018 = aggregate(housing2018, 'owned', 'Income- Restricted Ownership', '2018')
Insert cell
Insert cell
Insert cell
aggregate = (dataset, typeName, colName, year) => {
const cleanDataset = dataset.map(d => ({...d, neighborhood: d['Neighborhood'].toLowerCase()}))
const sums = d3.rollup(cleanDataset, v => d3.sum(v, d => d[colName]), d => d.neighborhood)
return [...sums.keys()]
.filter(k => k.length > 0)
.map(k => ({neighborhood: k, type: typeName, units: sums.get(k), year}));
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more