Public
Edited
Aug 21, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
athletes = aq.loadCSV(
"https://raw.githubusercontent.com/taniki/paris2024-data/main/datasets/athletes.csv"
)
Insert cell
athletes.view()
Insert cell
countries = athletes.dedupe(["country_code", "country_name"])
Insert cell
countries1 = athletes
.groupby(["country_code", "country_name"])
.count()
.orderby(aq.desc("count"))
.derive({
share: (d) => d.count / op.sum(d.count)
})
.derive({
cumshare: aq.rolling((d) => op.sum(d.share)),
row: op.row_number()
})
Insert cell
Inputs.table(countries1, { layout: "auto" })
Insert cell
medals = aq.loadCSV(
"https://raw.githubusercontent.com/taniki/paris2024-data/main/datasets/medal_countries.long.auto.csv"
)
Insert cell
Inputs.table(medals, { layout: "auto" })
Insert cell
gold = countries
.select({ country_code: "code" })
.join_left(
medals.filter((d) => d.medal == "gold"),
"code"
)
.impute({ quantity: () => 0 })
.derive({
share: (d) => d.quantity / op.sum(d.quantity)
})
.orderby(aq.desc("quantity"))
.derive({
cumshare: aq.rolling((d) => op.sum(d.share)),
row: op.row_number()
})
Insert cell
all = countries
.select({ country_code: "code" })
.join_left(
medals
.groupby(["code", "country"])
.rollup({ quantity: (d) => op.sum(d.quantity) }),
"code"
)
.impute({ quantity: () => 0 })
.derive({
share: (d) => d.quantity / op.sum(d.quantity)
})
.orderby(aq.desc("quantity"))
.derive({
cumshare: aq.rolling((d) => op.sum(d.share)),
row: op.row_number()
})
Insert cell
gold.view()
Insert cell
Inputs.table(gold, { layout: "auto" })
Insert cell
gold.numRows()
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