Public
Edited
Aug 8, 2023
Fork of Aya H - RN
Insert cell
Insert cell
Inputs.table(final_list)
Insert cell
final_list = clean_campy_data
.filter(aq.escape( d => bts_list.includes(d.Campaign) ))
.join_left(clean_repository, ['Campaign', 'Region'])
.derive({
cpl: d => d.spend / d.leads
})
.derive({
TCPA_based_CPL: d => d.activations == 0 ? 'network CPL' : d.tcpa / d.leads_per_activation
})
.select(0,12,13,14)
.derive({
was_active: aq.escape(d => clean_was_active.includes(d.Campaign) == true ? true : false)
})
.orderby(aq.desc('was_active'))
.objects()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof clean_campy_data = aq.from(raw_data)
.filter(d => d.Campaign != 'Do Not Sponsor' && d.Campaign != 'All Other' && d.Campaign != 'Min Bid')
.filter(d => op.includes(d.Campaign, 'Craigs') == false)
.derive({
spend: d => +op.replace(d.Actual, ',',''),
leads: d => +d['Paid Leads'],
activations: d => +d.Activations
})
.select('Campaign', 'Campaign group', 'Status', 'leads', 'activations','spend')
.derive({
leads_per_activation: d => d.leads / d.activations
})
.view()
Insert cell
raw_data = FileAttachment("lyft-by_campaign-2023-02-01-2023-02-28.csv").csv()
Insert cell
Insert cell
viewof clean_repository = aq.from(raw_repository)
//.filter(aq.escape(d => february_data_regions.includes(d.Region)))
.filter(aq.escape(d => bts_list.includes(d.Region)))
.derive({
tcpa: d => d['New TCPA'] == 'pause' ? 0 : op.replace(d['New TCPA'], '$', '')
})
.derive({
tcpa: d => +op.replace(d.tcpa, ',','')
})
.select('Region', 'New TCPA', 'City Name', 'State', '7-Aug', 'tcpa')
.orderby('Region')
//.filter(d => d.tcpa == 0)
.view({height: 800})
Insert cell
raw_repository = FileAttachment("Lyft Repository - Active Markets & Bids (15).csv").csv({typed: false})
Insert cell
february_data_regions = aq.from(raw_data)
.filter(d => d['Campaign group'] == 'Back To School')
.array('Campaign')
Insert cell
raw_bts_list = FileAttachment("Lyft Repository - Active Markets & Bids (11).xlsx").xlsx()
Insert cell
raw_bts_list_sheet = raw_bts_list.sheet('BTS List', {headers: true})
Insert cell
bts_list = aq.from(raw_bts_list_sheet)
.array('region')
Insert cell
clean_was_active = aq.from(raw_was_active_not_active)
.filter(d => d['activated on Aug 7'] == 'was active')
.array('region')
Insert cell
raw_was_active_not_active = FileAttachment("Lyft - was active and not.csv").csv()
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