Published
Edited
Mar 15, 2021
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
Insert cell
Insert cell
Insert cell
rawData = FileAttachment("city-of-boston-calendar-year-2020-earnings@3.csv").csv()
Insert cell
navio(rawData)
Insert cell
viewof earningsBoston = aq
.fromCSV(
await FileAttachment(
"city-of-boston-calendar-year-2020-earnings@3.csv"
).text()
)
.view({ height: 240 })
Insert cell
Insert cell
Insert cell
earningsBoston.select(0, 1, 3, 10, 11).view()
Insert cell
viewof cleanedEarnings = earningsBoston
.spread(
{ regular: d => op.split(d.REGULAR, '$') },
{ as: ["symbol", "earn"] }
)
.spread({ new: d => op.split(d.earn, ',') }, { as: ["before", "after"] })
.spread({ regular: d => +`${d.before}${d.after}` }, { before: "postal" })

.spread(
{ total_earnings: d => op.split(d.TOTAL_EARNINGS, '$') },
{ as: ["symbol2", "totalEarn"] }
)
.spread(
{ new: d => op.split(d.totalEarn, ',') },
{ as: ["symbol2", "totalEarn"] }
)
.spread({ total: d => +`${d.symbol2}${d.totalEarn}` }, { before: "postal" })

.select("NAME", "DEPARTMENT_NAME", "TITLE", "regular_1", "total_1", "POSTAL")
.view()
Insert cell
cleanedEarnings
.groupby("DEPARTMENT_NAME")
.rollup({
mean_regular: d => op.average(d.regular_1),
mean_total: d => op.mean(d.total_1)
})
.orderby("DEPARTMENT_NAME")
.view()
Insert cell
dataFinal = cleanedEarnings
.groupby("DEPARTMENT_NAME")
.rollup({
mean_regular: d => op.average(d.regular_1),
mean_total: d => op.mean(d.total_1)
})
.orderby("DEPARTMENT_NAME")
.objects()
Insert cell
dataFinal
Insert cell
Insert cell
Insert cell
import { navio } from "@john-guerra/navio"
Insert cell
import { aq, op } from '@uwdata/arquero'
Insert cell
import { Select } from "@observablehq/inputs"
Insert cell
import { vl } from "@vega/vega-lite-api"
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