A Python extension for Gloodata that displays fertility and demographic data from Our World in Data: Population & Demography Data Explorer.
- 🌍 World Map - Fertility rates across countries by year
- 📊 Population Pyramid - Age distribution by gender for any country and year
- 📈 Time Series Analysis - Demographic changes over time by age groups
- ℹ️ Country Information
- 📇 Country Directory - Table of all countries with regional information
Check that you are in a recent version of uv:
uv self update-
Clone the repository:
git clone https://github.com/gloodata/extension-demography.git cd extension-demography -
Run the extension:
uv run src/main.py
Available environment variables and their defaults:
EXTENSION_PORT:8089EXTENSION_HOST:localhost
For example, to change the port:
EXTENSION_PORT=6677 uv run src/main.pyInteractive pyramid chart showing male/female population by age groups
- "population pyramid for spain in 2023"
- "demography for india in 1950"
Tool: demography_by_country_and_year
Choropleth world map with color-coded fertility rates
- "world fertility for 2023"
- "fertility in 1950"
Tool: world_fertility_by_year
Multi-line chart showing population trends by age group
- "Demography timeserie for Spain"
- "Italy's demography over the years"
Tool: demography_by_country_over_time
Get detailed country information:
- "Information about Spain"
- "Italy's info"
Tool: country_infobox
Browse all available countries:
- "Show country table"
Tool: country_table
Files you may want to check first:
extension-demography/
├── src/
│ └── toolbox.py # Main extension logic
├── datawrangler.py # Script for merging `demography-*.csv` files into `demography.parquet`
└── queries.sql # SQL queries
rm -f ./demography.parquet
uv run datawrangler.py merge-demography-csvs -m ./demography-male.csv -f ./demography-female.csv -b ./demography-both.csv -o ./demography.parquetFor more information about the script:
uv run datawrangler.py -h- Define new SQL queries in
queries.sql - Create tool functions in
src/toolbox.pyusing the@tb.tooldecorator - Specify visualization types and parameters in the return dictionary
The project works with three main datasets:
countries.csv- Country metadata (ISO codes, regions, etc.)demography-*.csv- Raw demography datademography.parquet- Population data by age groups, country, and year- Processed with
datawrangler.py
- Processed with
fertility-rate.csv- Fertility rates by country and year
This project is open source and available under the MIT License.
For questions, issues, or contributions, please open an issue on GitHub or contact the maintainers.
