Public
Edited
May 5, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
o1 = model().drop('precipitation').data(weather)
Insert cell
Insert cell
Insert cell
o2 = model()
.drop("precipitation", "temp_max", "temp_min", "wind")
.data(weather)
Insert cell
Insert cell
Insert cell
o2a = model().filter((r)=>(r.temp_max < 0 && r.precipitation == 0)).data(weather)
Insert cell
Insert cell
Insert cell
o3 = model().group('island').data(penguins)
Insert cell
Insert cell
Insert cell
penguinsGrouped = model().group("island", "sex", "species").data(penguins)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
olympiansMerged = model().merge(olympiansNationality).data(olympiansSports)
Insert cell
Insert cell
Insert cell
penguinsGroupedSelected = model().select("island", "sex", "species").data(penguinsGrouped)
Insert cell
Insert cell
Insert cell
o4 = model()
.transform((t) => t.filter((r) => r.species == "Adelie"))
.data(penguinsGroupedSelected)
Insert cell
Insert cell
Insert cell
Insert cell
weatherMm = model().calc().called('precipitation (mm)').does((r)=>r.precipitation * 25.4).end().data(weather)
Insert cell
Insert cell
Insert cell
seattleWeather = model()
.transform((t) => t.filter((r) => r.location == "Seattle"))
.data(weatherMm)
Insert cell
Insert cell
Insert cell
function calcRunningTotal(r, getPrev) {
const previousRow = getPrev(1);
const previousRunningTotal =
previousRow === undefined ? 0 : previousRow["total precipitation (mm)"];
return r["precipitation (mm)"] + previousRunningTotal;
}
Insert cell
seattleWeatherPrecipitation = model()
.transform((t) => t.filter((r) => r.location == "Seattle"))
.calc()
.called("total precipitation (mm)")
.does(calcRunningTotal)
.end()
.data(weatherMm)
Insert cell
Insert cell
Insert cell
Insert cell
carsSalesTax = model().const().called("Sales Tax").value(20).end().data(cars)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
industriesInterpolated = model()
.interp()
.x("date")
.y("unemployed")
.groupBy("industry")
.end()
.data(industriesMissingData)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
knitted = model()
.knit()
.with(olympiansSportsSortedId)
.match("id")
.end()
.data(olympiansNationality)
Insert cell
Insert cell
Insert cell
penguinsReduced = model()
.reduce()
.add()
.called("min body mass")
.does((x) => d3.min(x, (d) => d["body_mass_g"]))
.end()
.add()
.called("max body mass")
.does((x) => d3.max(x, (d) => d["body_mass_g"]))
.end()
.add()
.called("avg body mass")
.does((x) => d3.mean(x, (d) => d["body_mass_g"]))
.end()
.groupBy("species", "island")
.end()
.data(penguins)
Insert cell
Insert cell
Insert cell
penguinsSorted = model()
.sort()
.dec("species")
.inc("body_mass_g")
.end()
.data(penguins)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
tidyCities = model()
.tidy()
.collapse("dehli", "tokyo", "lagos", "london")
.to("city")
.quantity("population")
.end()
.data(untidyCities)
Insert cell
Insert cell
Insert cell
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