Published
Edited
Sep 24, 2020
2 stars
Insert cell
Insert cell
Insert cell
tidied = {
var out =[]
json.forEach(d => {
let years = Object.keys(d).filter( k => /\d{4}/gi.test(k) ) // just get the yearlike entries
years.forEach(y => {
out.push({
name: d.CountryName,
code: d.CountryCode,
year: y,
value: d[y]
})
})
})
return out
}
Insert cell
getDataForYearRange = (min,max) => tidied.filter(d => d.year >= min && d.year <= max)
Insert cell
getDataForYearRange(1961,1962)
Insert cell
getDataForCountryCode = (code) => tidied.filter(d => d.code == code)
Insert cell
getDataForCountryCode("ZMB")
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