Public
Edited
Feb 16
Insert cell
Insert cell
biking = [
{ day: "Monday", miles: 6.2, time_hr: 0.53 },
{ day: "Tuesday", miles: 10.0, time_hr: 1.02 },
{ day: "Wednesday", miles: 4.9, time_hr: 0.48 },
{ day: "Thursday", miles: 0, time_hr: 0 },
{ day: "Friday", miles: 18.5, time_hr: 1.59 },
{ day: "Saturday", miles: 7.3, time_hr: 0.86 },
{ day: "Sunday", miles: 0, time_hr: 0 }
]
Insert cell
biking[4].miles
Insert cell
biking.map(d => d.miles / d.time_hr)
Insert cell
biking.filter(d => d.miles > 10)
Insert cell
biking.filter(d => d.day == "Saturday" || d.day == "Monday")
Insert cell
biking.filter(d => d.miles < 10 && d.time_hr < 0.5)
Insert cell
biking.filter(d => d.day !="Thursday")
Insert cell
biking_km = biking.map(d => ({...d, km: d.miles * 1.61}))
Insert cell
import {carData} from "@observablehq/intro-js-session-2-key"
Insert cell
carTable = aq.from(carData)
Insert cell
carTable
.select("name", "economy (mpg)", "cylinders", "weight (lb)")
.filter((d) => d.cylinders == 4 && d['economy (mpg)'] != null)
.derive({weight_kg: d => d['weight (lb)'] * 0.45})
.orderby('economy (mpg)')
.rename({'economy (mpg)': 'mpg'})
Insert cell
carTable
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
wb1 = FileAttachment("wb@1.csv").csv()
Insert cell
wb1
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
wb2019 = wb.map(d => ({ country: d.country, year: d.year, region: d.region, co2_thousands: d.co2 / 1000}))
.filter(d => d.year == 2019)
Insert cell
wbTable = aq.from(wb)
Insert cell
wb2019
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Plot.plot({
marks: [
Plot.barX(wb2019, {
x: (d) => d.co2_thousands,
y: "country",
fill: "red",
stroke: "gray",
sort: { y: "y", reverse: false, limit: 20 }
}),
Plot.text(wb2019, {
x: (d) => d.co2_thousands,
y: "country",
text: (d) => d.co2_thousands,
dx: 2,
textAnchor: "start"
}),
Plot.ruleX([0])
],
marginLeft: 200,
x: { domain: [0, 30], grid: true, label: "CO2" }
})
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