Public
Edited
Sep 22, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
allResults = data
.fold(
aq.not('Canvasser'), {as: ['result', 'result_count']}
)
.groupby('result')
.rollup({
result_count: aq.op.sum('result_count'),
})
Insert cell
allResults
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Insert cell
Insert cell
canvassers2
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
canvassers = data
.rename({Canvasser: 'name'})
.groupby('name')
.derive(
{ shift_count: d => aq.op.count() },
{ after: 'name' }
)
.fold(
aq.not('name', 'shift_count'), {as: ['result', 'result_count']}
)
.groupby('name')
.derive(
{ door_count: d => aq.op.sum(d.result_count) },
{ after: 'shift_count' }
)
.groupby('name', 'shift_count', 'door_count')
.pivot(
{ key: d => `${aq.op.replace(aq.op.lower(d.result), ' ', '_')}_count`},
{ value: aq.op.sum('result_count') }
)
.derive(
{ contact_count: d => d.canvassed_count + d.refused_count },
{ after: "door_count" }
)
.derive(
{ contact_per_door: d => (d.canvassed_count + d.refused_count) / d.door_count },
{ after: 'door_count' }
)
.derive(
{ not_home_per_door: d => d.not_home_count / d.door_count },
{ after: 'contact_per_door' }
)
.derive(
{ canvassed_per_contact: d => d.canvassed_count / d.contact_count },
{ after: 'contact_per_door' }
)
.derive(
{ refused_per_contact: d => d.refused_count / d.contact_count },
{ after: 'canvassed_per_contact' }
)
.orderby(aq.desc('contact_per_door'))
// .derive(
// { contact_per_shift_rate: d => d.canvassed_count / d.door_count },
// { after: 'contact_rate' }
// )
Insert cell
canvassers.toCSV()
Insert cell
canvassers
Type Table, then Shift-Enter. Ctrl-space for more options.

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