Public
Edited
Feb 12
1 fork
Insert cell
md`# My first exercise`
Insert cell
d3 = require("d3@5")
Insert cell
topojson = require("topojson-client@3")
Insert cell
states = FileAttachment("nystate.json").json()
Insert cell
states_features = topojson.feature(states, states.objects.ny)
Insert cell
csv_data = d3.csvParse(await FileAttachment("states48.csv").text(),({STATE_FIPS, FEMALES, POP2010, AGE_5_9}) => [+STATE_FIPS, [100*+AGE_5_9/POP2010, 100*+FEMALES/POP2010]])
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[1][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: ["Females", "Female Pct"]})
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