Public
Edited
Sep 16, 2024
1 fork
Insert cell
Insert cell
Insert cell
4+2+3
Insert cell
Insert cell
result = 4+2+3
Insert cell
Insert cell
newResult = result + 2
Insert cell
Insert cell
multiplication = 2 * 10
Insert cell
multiplication * 5
Insert cell
Insert cell
import { aq, op } from '@uwdata/arquero'
Insert cell
Insert cell
aq
Insert cell
Insert cell
viewof trains = aq // viewof shows the table view, but assigns the table value
.fromCSV(await FileAttachment('small_trains.csv').text())
.view({ height: 240 }) // set maximum height of table viewer in pixels
Insert cell
Insert cell
trains
.orderby('year')
.view(100) // cela va nous montrer que les premières 100 lignes
Insert cell
Insert cell
trains
.orderby('year')
.select('year','month', 'service', 'total_num_trips', 'departure_station', 'arrival_station')
.view(100)
Insert cell
Insert cell
Insert cell
trains.orderby('delayed_number').select('month', 'year', 'delayed_number', 'departure_station', 'arrival_station','delay_cause').view(10)
Insert cell
trains.orderby('year','month','departure_station', 'arrival_station').select('month', 'year', 'delayed_number', 'departure_station', 'arrival_station', 'delay_cause','avg_delay_all_arriving').view(10)
Insert cell
Insert cell
Insert cell
trains
.filter(d => d.service == "National").view()
Insert cell
Insert cell
trains
.filter(d => { return d.service == "National"}).view()
Insert cell
Insert cell
trains
.filter(d => { return d.service == "National" && d.year==2015}).view()
Insert cell
Insert cell
filtered = trains
.filter(d => d.service == "National").reify()
Insert cell
Insert cell
trains.filter(d=>d.service == 'International' && d.year == 2017).view()
Insert cell
trains.filter(d=>d.arrival_station == "PARIS LYON" && d.service == 'International' && d.year == 2017).view()
Insert cell
trains.filter(d=>d.arrival_station == "PARIS LYON").view()
Insert cell
Insert cell
trains
.rollup({
mean_journey_time_avg: d => op.mean(d.journey_time_avg), // op.average is available as a synonym
mean_total_num_trips: d => op.mean(d.total_num_trips),
mean_avg_delay_all_departing: d => op.mean(d.avg_delay_all_departing),
mean_avg_delay_all_arriving: d => op.mean(d.avg_delay_all_arriving),
corr_journey_time_avg_avg_delay_all_departing: d => op.corr(d.journey_time_avg, d.avg_delay_all_departing)
})
.view()
Insert cell
Insert cell
trains
.groupby('service')
.rollup({
mean_journey_time_avg: d => op.mean(d.journey_time_avg), // op.average is available as a synonym
mean_total_num_trips: d => op.mean(d.total_num_trips),
mean_avg_delay_all_departing: d => op.mean(d.avg_delay_all_departing),
mean_avg_delay_all_arriving: d => op.mean(d.avg_delay_all_arriving),
}).view()
Insert cell
trains
.groupby('service', 'year')
.rollup({
mean_journey_time_avg: d => op.mean(d.journey_time_avg), // op.average is available as a synonym
mean_total_num_trips: d => op.mean(d.total_num_trips),
mean_avg_delay_all_departing: d => op.mean(d.avg_delay_all_departing),
mean_avg_delay_all_arriving: d => op.mean(d.avg_delay_all_arriving),
}).view()
Insert cell
Insert cell
trains
.groupby('year')
.rollup({
mean_journey_time_avg: d => op.mean(d.journey_time_avg), // op.average is available as a synonym
mean_total_num_trips: d => op.mean(d.total_num_trips),
mean_avg_delay_all_departing: d => op.mean(d.avg_delay_all_departing),
mean_avg_delay_all_arriving: d => op.mean(d.avg_delay_all_arriving),
}).view()
Insert cell
trains
.groupby('year', 'departure_station', 'arrival_station')
.rollup({
max_avg_delay_all_arriving: d => op.max(d.avg_delay_all_arriving)
}).orderby(aq.desc("max_avg_delay_all_arriving")).view()
Insert cell
trains
.groupby('arrival_station', 'departure_station')
.rollup({
mean_delayed_number: d => op.mean(d.delayed_number),
}).orderby(aq.desc('mean_delayed_number')).view()
Insert cell
trains
.groupby('year')
.rollup({
mean_avg_delay_all_departing: d => op.mean(d.avg_delay_all_departing),
mean_avg_delay_all_arriving: d => op.mean(d.avg_delay_all_arriving),
}).view()
Insert cell
trains
.groupby('month')
.rollup({
mean_avg_delay_all_departing: d => op.mean(d.avg_delay_all_departing),
mean_avg_delay_all_arriving: d => op.mean(d.avg_delay_all_arriving),
}).view()
Insert cell
Insert cell
trains.derive({ arrivingDelayPercent: d => d.num_arriving_late/d.total_num_trips * 100 }).view()
Insert cell
trains.derive({ isLateAtDeparture: d => d.num_late_at_departure !=0 }).view()
Insert cell
trains.derive({ isLaterThan15Minutes: d => d.avg_delay_all_departing > 15 || d.avg_delay_all_arriving > 15 }).view()
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