Published
Edited
Jan 31, 2022
Importers
Insert cell
Insert cell
import {buildURI} from "@weiglemc/using-the-soda-api-to-access-data-from-the-virginia-open-data"
Insert cell
Insert cell
uri = buildURI("5s4f-hthh", 12000, "&year=2019")
Insert cell
// get data from API, file attachment, or GitHub
data = (await fetch(uri)).json()
//data = FileAttachment("va-population-2019.csv").csv()
//data = d3.csv("https://raw.githubusercontent.com/odu-cs725-infovis/public/main/va-population-age-race2019.csv")
Insert cell
Insert cell
printTable(data.slice(0,10))
Insert cell
Insert cell
data.forEach(d => {
d.population_estimate = +d.population_estimate
});
Insert cell
Insert cell
locality_flat = d3.flatRollup(data, v => d3.sum(v, d => d.population_estimate),
d=>d.locality,
d=>d.fips,
d=>d.health_district,
d=>d.health_region)
Insert cell
Insert cell
locality_json = locality_flat.map(obj => { let rObj= {}; rObj["locality"] = obj[0]; rObj["fips"] = obj[1]; rObj["health_district"] = obj[2]; rObj["health_region"]= obj[3]; rObj["population_estimate"] = obj[4]; return rObj;})
Insert cell
locality_json.length
Insert cell
printTable(locality_json.slice(0,10))
Insert cell
Insert cell
viewof raw_pop = aq.from(data).view({height:150})
Insert cell
Insert cell
viewof state_population = raw_pop
.groupby('locality')
.derive({population: op.sum('population_estimate')})
.select(aq.not('age_group', 'sex', 'race_and_ethnicity', 'population_estimate'))
.filter(d => op.rank() === 1)
.orderby('locality')
.view({height:200})
Insert cell
state_population.numRows()
Insert cell
Insert cell
state_population.toCSV()
Insert cell
Insert cell
import {printTable} from "@uwdata/data-utilities"
Insert cell
d3 = require("d3@6", "d3-array@^3")
Insert cell
import { aq, op } from '@uwdata/arquero'
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