Published
Edited
Feb 11, 2021
3 forks
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
rawData = FileAttachment("StockX-Data-Contest-2019-3.csv").csv()
Insert cell
Insert cell
Insert cell
stateData = FileAttachment("state-abbrevs.csv").csv()
Insert cell
Insert cell
Insert cell
data = rawData.map(d => ({
buyer_region: d.Buyer_Region,
brand: d.Brand,
sneaker_name: d.Sneaker_Name
}))
Insert cell
viewof df = aq.from(data).view()
Insert cell
viewof dsf = aq.from(stateData).view()
Insert cell
viewof finalSneaker = df.join(dsf, ["buyer_region", "state"]).view()
Insert cell
Insert cell
Insert cell
columns = ["abbreviation", "brand", "sneaker_name"]
Insert cell
viewof groupKey = Select(["abbreviation"], { label: "Group by" })
Insert cell
viewof colorKey = Select(["brand"], { label: "Color by", value: ["brand"] })
Insert cell
viewof groupPivotedData = finalSneaker
.select(groupKey, colorKey)
.groupby(groupKey, colorKey)
.count()
.groupby(groupKey)
.pivot(colorKey, "count")
.view()
Insert cell
chartData = groupPivotedData.objects()
Insert cell
finalData = Object.assign(chartData, { y: "Number of Sneakers Bought" })
Insert cell
keys = df
.groupby(colorKey)
.count()
.column(colorKey).data
Insert cell
Insert cell
import { navio } from "@john-guerra/navio"
Insert cell
import { aq, op } from '@uwdata/arquero'
Insert cell
import { Select } from "@observablehq/inputs"
Insert cell
import { chart } with {
finalData as data,
groupKey,
keys
} from "@d3/grouped-bar-chart"
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