Public
Edited
Jun 15, 2023
Insert cell
Insert cell
Insert cell
file.name
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof color_for_zero = Inputs.color({label: "Zero color", value: "#ffc2b3"})
Insert cell
my_color = [color_for_zero].concat(d3.schemeBuPu[3])
Insert cell
my_color2 = [color_for_zero].concat(d3.schemeBuPu[5])
Insert cell
Insert cell
Insert cell
Insert cell
viewof by_req = clean
.groupby('date', 'segment', 'req_number')
.rollup({
spend: d => op.sum(d.spend),
applies: d => op.sum(d.applies)
})
.derive({
cpa: d => d.spend / d.applies
})
.view()
Insert cell
by_req_group_filtered = clean
.filter(aq.escape(d => d.job_group == job_group_selector))
.objects()
Insert cell
by_req_segment_type_filtered = by_req_group_filtered
.filter(d => d.segment_type == segment_type_selector)
Insert cell
viewof by_req_segment_filtered = aq.from(by_req_segment_type_filtered)
.filter(aq.escape(d => d.segment == campaign_selector))
.groupby('date', 'req_number')
.rollup({
spend: d => op.sum(d.spend),
applies: d => op.sum(d.applies),
clicks: d => op.sum(d.clicks)
})
.derive({
cpa: d => d.spend / d.applies,
CtoA: d => d.applies / d.clicks
})
.view()
Insert cell
by_campy_filtered = by_campy.objects().filter(d => d.job_group == job_group_selector)
Insert cell
viewof by_campy = clean
.filter(d => d.parent_campaign != null)
.groupby('date', 'parent_campaign', 'job_group')
.rollup({
clicks: d => op.sum(d.clicks),
applies: d => op.sum(d.applies),
spend: d => op.sum(d.spend),
reqs: d => op.array_agg(d.req_number),
req_count: d => op.distinct(d.req_number)
})
.derive({
cpa: d => d.spend / d.applies,
CtoA: d => d.applies / d.clicks
})
.view()
Insert cell
Insert cell
viewof clean = aq.from(raw_data)
.filter(aq.escape(d => d.date >= start_date && d.date <= end_date))
.derive({
job_group: d => op.includes(op.lower(d.parent_campaign), 'allied') == true ? 'Allied' :
op.includes(op.lower(d.parent_campaign), 'school') == true ? 'schools/education' :
op.includes(op.lower(d.parent_campaign), 'therapy/rehab') == true ? 'therapy/rehab' :
op.includes(op.lower(d.parent_campaign), 'per diem') == true ? 'per diem' :
op.includes(op.lower(d.parent_campaign), 'rn') == true ? 'RN' :
'Other'
})
.derive({
segment_type: d => op.includes(op.lower(d.segment), 'low submissions') == true ? 'low submissions' :
op.includes(op.lower(d.segment), 'strategic') == true ? 'strategic' :
op.includes(op.lower(d.segment), 'catch') == true ? 'catch all' :
'Other'
})
.view()
Insert cell
raw_data = file.csv({typed: true})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// this is a really cool way of displaying tables. Much more aesthetically pleasing than the defaults of arquero and input.table

import { formatTable } from "@saneef/pretty-tables"
Insert cell
Insert cell
import {toc} from "@nebrius/indented-toc"
Insert cell
Insert cell
date_parser = d3.utcParse('%m/%d/%Y')
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// sample of how to place html blocks in a grid

// html `<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; column-gap: 0px; row-gap: 5px;">
// ${viewof spend}
// ${viewof cpl}
// ${viewof cpc}
// </div>`
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