Public
Edited
Feb 13
Insert cell
md`# My first exercise`
Insert cell
d3 = require("d3@5")
Insert cell
topojson = require("topojson-client@3")
Insert cell
counties = FileAttachment("US_County_2020_WGS84.json").json()
Insert cell
county_features = topojson.feature(counties, counties.objects.US_County_2020_WGS84)
Insert cell
csv_data = d3.csvParse(await FileAttachment("Education.csv").text(), ({STATE, COUNTY, ASP2E035, ASP2E018, ASP2E001}) => STATE === "Iowa" ? [COUNTY, ((+ASP2E018 + +ASP2E035)/+ASP2E001)*100] : null
).filter(d => d);
Insert cell
//this is how to take the values of a variable (column) from all variables you created from the csv file
femalepct = Array.from(csv_data.values(), d => [d[0], 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: ["Counties", "Percentage of people with doctorates"]})
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