Public
Edited
Jul 12, 2024
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
raw_data = {
yield d3.json(
"https://raw.githubusercontent.com/alex/nyt-2020-election-scraper/master/results.json"
);
while (true) {
yield Promises.delay(
1000 * 60 * 5,
d3.json(
"https://raw.githubusercontent.com/alex/nyt-2020-election-scraper/master/results.json"
)
);
}
}
Insert cell
Insert cell
Insert cell
Insert cell
updates_js = raw_data.data.races
.filter((r) => r.race_slug.includes("president")) // only want presidential races
.flatMap((r) =>
r.timeseries.map((update) => ({
Reporting: update.eevp / 100,
percent_Trump: update.vote_shares.trumpd,
percent_Biden: update.vote_shares.bidenj,
timestamp: update.timestamp,
state: r.state_name
}))
)
Insert cell
Insert cell
Insert cell
viewof updates_aq = aq
.from(updates_js)
.derive({
Conservatism: (r) =>
r.percent_Trump / (r.percent_Biden + r.percent_Trump) - 0.5
})
.filter((r) => !op.is_nan(r.Conservatism))
.view()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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