Public
Edited
Aug 23, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { get_labels } from "@pac02/what-kind-of-articles-have-you-created"
Insert cell
group_labels = get_labels(
["Q41550", "Q1764511", "Q458", "Q7159", "Q19771"],
"en"
).then((d) => d.objects())
Insert cell
group_map = new Map(
group_labels.map(({ label, qid }) => [label + " (" + qid + ")", qid])
)
Insert cell
Insert cell
medals = aq.fromCSV(
await fetch(
`https://raw.githubusercontent.com/taniki/paris2024-data/main/datasets/medal_countries.long.auto.csv`
).then((d) => d.text()),
{
delimiter: ",",
autoType: true
}
)
Insert cell
Inputs.table(medals, { layout: "auto" })
Insert cell
athletes = aq.loadCSV(
"https://raw.githubusercontent.com/taniki/paris2024-data/main/datasets/athletes.csv"
)
Insert cell
countries = athletes.dedupe(["country_code", "country_name"])
Insert cell
query = `SELECT DISTINCT ?item ?itemLabel ?code WHERE {
?item wdt:P984 ?code;
wdt:P463 wd:${group}.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}`
Insert cell
output = fetch(
`https://query.wikidata.org/sparql?query=${encodeURIComponent(query)}`,
{ headers: { accept: "application/sparql-results+json" } }
).then((response) => response.json())
Insert cell
members = aq.from(
output.results.bindings.map((d) => ({
item: d.item.value,
itemLabel: d.itemLabel.value,
code: d.code.value
}))
)
Insert cell
members.numRows()
Insert cell
Inputs.table(members, {
columns: ["itemLabel", "code"],
layout: "auto"
})
Insert cell
groupA = medals.semijoin(members, ["code", "code"])
Insert cell
groupB = medals.antijoin(members, ["code", "code"])
Insert cell
Inputs.table(groupA)
Insert cell
Insert cell
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