Public
Edited
Jul 23, 2024
Insert cell
Insert cell
printTable(flights.slice(0, 5)) // display the first five rows
Insert cell
data['flights-10k.json'].url
Insert cell
Insert cell
Insert cell
flights.filter(flight => flight.delay < 0).sort((a, b) => a.delay - b.delay)
Insert cell
new Set(flights.map(f => f.origin))
Insert cell
Insert cell
_.orderBy(flights.filter(flight => flight.origin === 'SJC' || flight.destination === 'SJC'),
['origin', 'destination'], ['asc', 'desc'])
Insert cell
Insert cell
{
const regexp = /DAL|HOU/; // new RegExp('DAL|HOU')

return flights.filter(flight => flight.origin.match(regexp))
}
Insert cell
{
const airports = ['DAL', 'HOU'];

return flights.filter(flight => airports.indexOf(flight.origin) !== -1);
}
Insert cell
Insert cell
d3.extent(flights.map(f => f.date))
Insert cell
flights
.filter((flight) => flight.date >= new Date("2001-03-01"))
.sort((a, b) => a.date - b.date)
Insert cell
Insert cell
flights
.filter(
(flight) =>
flight.date >= new Date("2001-01-01") &&
flight.date < new Date("2001-02-01")
)
.sort((a, b) => a.date - b.date)
Insert cell
Insert cell
Insert cell
{
const keepCols = ['origin', 'destination'];

const selectedData = flights.map(obj => {
let tmpObj = {};
selectColsByName(tmpObj, obj, keepCols);
return tmpObj;
});

return selectedData
}
Insert cell
Insert cell
Insert cell
{
const keepCols = /de/;

const selectedData = flights.map(obj => {
let tmpObj = {};
selectColsByRegExp(tmpObj, obj, new RegExp(keepCols));
return tmpObj;
});

return selectedData;
}
Insert cell
Insert cell
Insert cell
flights = (await data['flights-10k.json']()).map(f => ({ ...f, date: new Date(f.date) }))
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