Public
Edited
Aug 21, 2023
Fork of Untitled
1 fork
Insert cell
md `# Canada Weekly`
Insert cell
Insert cell
raw_indeed_rn = file.csv({typed: true})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
last_monday = d3.utcMonday(d3.utcDay.offset(new Date(), -7))
Insert cell
spend_table = clean
.filter(aq.escape(d => +d3.utcDay(d.week) == +last_monday))
.join(spend_sort_table, ['title', 'title'])
.orderby(aq.desc('agg_leads'))
.objects()
Insert cell
viewof spend_sort_table = clean
.groupby('title')
.rollup({
leads: d => op.sum(d.leads)
})
.rename({leads: 'agg_leads'})
.orderby(aq.desc('agg_leads'))
.view('title')
Insert cell
Insert cell
Insert cell
Plot.lineY(cleaner, Plot.binX({y: 'sum'},{x: 'week', y: 'leads', thresholds: d3.utcMonday})).plot()
Insert cell
viewof cleaner = clean.view()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof clean = aq.from(raw_indeed_rn)
.filter(aq.escape(d => d.date >= start_date && d.date <= end_date))
.derive({
week: aq.escape(d => d3.utcMonday(d.date))
})
.groupby('week', 'title')
.rollup({
spend: d => op.sum(d.spend),
leads: d => op.sum(d.leads)
})
.derive({
cpl: d => d.spend / d.leads
})
.filter(d => op.includes(d.title, 'Default') == false)
.orderby('week')
.view()
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