Public
Edited
Jun 29, 2023
7 forks
11 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
unemploymentWide = unemploymentBLS.sheet(0, {headers: true})
Insert cell
unemploymentWide
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
unemploymentTall = aq.from(unemploymentWide) // create an arquero table from our data
.fold(aq.not('Year'), { as: ['Month', 'Unemployment'] }) // unpivot/fold the data by year, create columns Month and Unemployment
.objects() // turn it back into a JavaScript array of objects
Insert cell
Insert cell
unemploymentTall
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
lineData = unemploymentTall.map(row => ({
Date: d3.utcParse("%Y %b")(row.Year + " " + row.Month), //parse year and month into a proper date object
Unemployment: row.Unemployment //copy the unemployment column without change
}))
Insert cell
Plot.plot({
marks: [
Plot.ruleY([0]),
Plot.lineY(lineData, {x: "Date", y: "Unemployment"})
]
})
Insert cell
Insert cell
data
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
data
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
unemploymentBLS = FileAttachment("SeriesReport-20230614144010_3ed09f-cropped.xlsx").xlsx({})
Insert cell
data = cars
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more