Public
Edited
May 23, 2023
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
Inputs.table(final_zip_list)
Insert cell
Insert cell
Inputs.table(zip_list_summary)
Insert cell
act = Plot.plot({
width: 200,
marginLeft: 50,
y: {
label: null
},
marks: [
Plot.axisX({anchor: 'top', tickFormat: '%', label: 'Zip codes with Activations'}),
Plot.barX(final_zip_list.filter(d => d.status == 'active'), Plot.groupY({x: 'count'},{
y: 'title',
fill: 'has_activations',
offset: 'normalize'
}))
]
})
Insert cell
aq.from(zip_list_summary)
.view()
Insert cell
final_zip_list = clean
.filter(d => op.includes(op.lower(d.title), 'craigs') == false)
.derive({
has_activations: d => d.activations > 0 ? 'has_activations' : 'no_activations'
})
// .derive({
// has_activations: d => d.bgc > 0 ? 'has_bgc' : 'no_bgc'
// })
.select('title', 'job_postal_code', 'has_activations')
.dedupe('job_postal_code')
.derive({title: d => op.trim(d.title)})
.derive({
status: aq.escape( d => active_campys.includes(d.title) == true ? 'active' : 'paused' )
})
.orderby('title', 'status', 'has_activations')
.objects()
Insert cell
md `## active campaign list`
Insert cell
Insert cell
raw_active_campys = FileAttachment("lyft-by_campaign-2023-05-17-2023-05-17.csv").csv()
Insert cell
Insert cell
viewof cr = clean
.filter(d => op.includes(op.lower(d.title), 'craigs') == false)
.filter(aq.escape(d => active_campys.includes(d.title) == true))
.filter(d => d.title != 'All Other')
.groupby('title')
.rollup({
leads: d => op.sum(d.leads),
bgc: d => op.sum(d.bgc),
activations: d => op.sum(d.activations)
})
.derive({
LtoBGC: d => d.bgc / d.leads,
BGCtoA: d => d.activations / d.bgc
})
.orderby('title')
.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
clean_campaign_filtered = clean.objects().filter(d => d.title == campaign_selector)
Insert cell
viewof clean = aq.from(raw_data)
.derive({date: d => op.parse_date(d.date)})
.derive({
month_date: aq.escape(d => d3.utcMonth(d.date))
})
.groupby('title', 'job_postal_code')
.rollup({
spend: d => op.sum(d.spend),
leads: d => op.sum(d.leads),
bgc: d => op.sum(d.bgc),
activations: d => op.sum(d.activations)
})
.join_left(aq.from(zips_clean), ['job_postal_code', 'zip_code'])
.derive({
latitude: d => +d.latitude,
longitude: d => +d.longitude
})
.view()
Insert cell
viewof clean_time = aq.from(raw_data)
.derive({date: d => op.parse_date(d.date)})
.derive({
month_date: aq.escape(d => d3.utcMonth(d.date))
})
.groupby('date', 'title')
.rollup({
spend: d => op.sum(d.spend),
leads: d => op.sum(d.leads),
bgc: d => op.sum(d.bgc),
activations: d => op.sum(d.activations)
})
.derive({
LtoBGC: d => d.bgc / d.leads,
BGCtoA: d => d.activations / d.bgc
})
.view()
Insert cell
raw_data = file.csv({typed: false})
Insert cell
Insert cell
Insert cell
zips_clean = d3.csv(zips)
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