Public
Edited
May 18
Insert cell
Insert cell
d3 = require("d3@7")

Insert cell
Insert cell
rawCPI = FileAttachment("YearMonCPI.csv").csv({typed: true})
Insert cell
cpiData = rawCPI.flatMap(row => {
const year = row.Year;
return Object.entries(row)
.filter(([month]) => month !== "Year")
.map(([month, value]) => ({
date: new Date(`${year}-${month}-01`),
value: value
}));
})

Insert cell
rawWages = FileAttachment("MedianRealWageQuarterly.csv").csv({typed: true})

Insert cell
wageData = rawWages.flatMap(row => {
const year = row.Year;
return ["Qtr1", "Qtr2", "Qtr3", "Qtr4"].map((qtr, i) => ({
date: new Date(`${year}-${(i + 1) * 3 - 1}-01`), // Q1 = March, Q2 = June, etc.
value: row[qtr]
}));
})

Insert cell
combinedData = [
...cpiData.map(d => ({date: d.date, value: d.value, series: "CPI"})),
...wageData.map(d => ({date: d.date, value: d.value, series: "Wage"}))
]

Insert cell
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