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

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