Public
Edited
Jan 22, 2024
Insert cell
Insert cell
Insert cell
Insert cell
import { aq, op } from '@uwdata/arquero'
Insert cell
embed = require("vega-embed@5")
Insert cell
Insert cell
viewof trajets = aq // viewof shows the table view, but assigns the table value
.fromCSV(await FileAttachment('trajets.csv').text())
.view({ height: 240 })
Insert cell
viewof trajets_new = aq // viewof shows the table view, but assigns the table value
.fromCSV(await FileAttachment('trajets_drop2018.csv').text())
.view({ height: 240 })
Insert cell
trajets_new_grouped = trajets_new.groupby('DEP', 'ARR',
'DEP_LAT', 'DEP_LONG',
'ARR_LAT', 'ARR_LONG').rollup({total_NVOLS: d=> op.sum(d.NVOLS),
total_passengers: d=>op.sum(d.PAX_FS)} ).filter((d)=> d.DEP_LAT != null & d.DEP_LONG !=null& d.ARR_LAT!=null)
Insert cell
trajets_new_grouped.view()
Insert cell
// for each airport, we aggregate number of departing flights and passengers
//also get lat and long values. here max() has no meaning since the values will be same for each airport, but we are bound use an aggregating function
departures = trajets_new.groupby('DEP').rollup({dep_flights: d => op.sum(d.NVOLS),
dep_passengers: d=>op.sum(d.PAX_FS),
lat: d=> op.max(d.DEP_LAT),
lon: d => op.max(d.DEP_LONG)})
Insert cell
arrivals = trajets_new.groupby('ARR').rollup({arr_flights: d => op.sum(d.NVOLS),
arr_passengers: d=>op.sum(d.PAX_FS)})
Insert cell
// Join arrivals and departures
arr_dep = departures.join_left(arrivals, ['DEP', 'ARR'])
Insert cell
arr_dep.view()
Insert cell
arrivals_year = trajets_new.groupby('ARR','year').rollup({arr_flights: d => op.sum(d.NVOLS),
arr_passengers: d=>op.sum(d.PAX_FS),
lat: d=> op.max(d.ARR_LAT),
lon: d => op.max(d.ARR_LONG)}).filter((d) => d.lat != null & d.lon !=null)
.reify();
Insert cell
arrivals_year.view()
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
max_passengers=trajets_new_grouped.rollup({ max_passengers: d => op.max(d.total_passengers) }).objects()[0].max_passengers
Insert cell
min_passengers=trajets_new_grouped.rollup({ min_passengers: d => op.min(d.total_passengers) }).objects()[0].min_passengers
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