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

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