Public
Edited
Feb 21, 2023
Insert cell
md`# Assignment 1, new data`
Insert cell
d3 = require("d3@5")
Insert cell
topojson = require("topojson-client@3")
Insert cell
Counties = FileAttachment("tl_2016_53_cousub.json").json()
Insert cell
counties_features = topojson.feature(Counties, Counties.objects.tl_2016_53_cousub)
Insert cell
csv_data = d3.csvParse(await FileAttachment("DECENNIALPL2020@1.P1-Data.csv").text(),({GeographicAreaName, TotalWhite, TotalAfricanAmerican, TotalPop}) => [GeographicAreaName, [+TotalWhite, +TotalWhite/+TotalPop]])
Insert cell
//this is how to take the values of a variable (column) from all variables you created from the csv file
Populationpct = Array.from(csv_data.values(), d => d[1])
Insert cell
//this is how you map the id column to the values. We will use this for joining with topojson later.
data = Object.assign(new Map(csv_data), {title: ["Pct of Pop, White"]})
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