On the side of my full-time job as the CEO of a small machine-learning company, my hobby is creating beautiful data visualizations.
I usually do that using Matplotlib, but I wanted to create a more interactive experience this time.
Since I enjoy web development and design, I decided to create a React application for the Population Estimates And Projections dataset from the World Bank.
It’s a fascinating dataset where you can look at population pyramids for all countries and regions from 1960 to 2022, including projections to 2050. It’s licensed under Creative Commons Attribution 4.0.
It’s also a dataset well suited for an interactive interface where people can change years and regions quickly.
In this story, I’ll share insights from my work and what I learned.
If you want to test the solution, you can find it here: https://datawonder.io/population-pyramids
Let’s get started.
I wanted to create a simple and fast backend that serves data to the front end without doing any time-consuming preprocessing.
Instead, my idea was to do all the data ahead of time and load it all into memory when the applications start.
The World Bank data always have a set of indicators, and the ones I want have the following format:
There are 17 age groups ranging from 0–4 and 80+. Each indicator has a separate column for every year, like in the pandas data frame below.
Since I knew exactly what parts of the data I needed and didn’t want to do any filtering or other operations…