Public
Edited
Jun 21, 2023
10 forks
Insert cell
Insert cell
Insert cell
file.name
Insert cell
viewof file2 = Inputs.file({label: "Data"})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
clean2 = aq.from(parsed_data2)
.derive({
date: d => op.parse_date(d['Time of Budge change']),
Before: d => op.parse_int(d.Before),
After: d => op.parse_int(d.After)
})
.orderby('Employer name', 'Campaign name', 'date')
.groupby('Employer name', 'Campaign name')
.rollup({
before_values: d => op.array_agg(d.Before),
after_values: d => op.array_agg(d.After)
})
.derive({
earliest_value: aq.escape(d => d.before_values.at(0)),
last_value: aq.escape(d => d.after_values.at(-1))
})
.derive({
difference_pre_post: d => d.last_value - d.earliest_value
})
.view()
Insert cell
parsed_data2 = raw_data2.sheet('Sheet1', {headers: true})
Insert cell
raw_data2 = file2.xlsx()
Insert cell
Insert cell
viewof formatted_file = Inputs.table(clean2, {
layout: 'auto'
})
Insert cell
// blob to download file above
blob = new Blob([d3.csvFormat(formatted_file)], {type: "text/csv"})
Insert cell
DOM.download(blob)
Insert cell
Insert cell
clean = aq.from(parsed_data)
.derive({
date: d => op.parse_date(d['Time of Budge change']),
Before: d => op.parse_int(d.Before),
After: d => op.parse_int(d.After)
})
.orderby('Employer name', 'Campaign name', 'date')
.groupby('Employer name', 'Campaign name')
.rollup({
before_values: d => op.array_agg(d.Before),
after_values: d => op.array_agg(d.After)
})
.derive({
earliest_value: aq.escape(d => d.before_values.at(0)),
last_value: aq.escape(d => d.after_values.at(-1))
})
.derive({
difference_pre_post: d => d.last_value - d.earliest_value
})
.objects()
Insert cell
parsed_data = raw_data.sheet('Sheet1', {headers: true})
Insert cell
raw_data = file.xlsx()
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