On track for 2030?
Three lines to a spreadsheet
Search, get, save: an Excel file with its sources.
Lesson 1 of 6 · Analyse it in Python
Try it yourself
- Run it in Colab, with nothing to install
-
pip install undata -
import undata as un un.search("maternal mortality") -
table = un.get("3.1.1", ["Bangladesh", "Viet Nam"]) un.save(table, "maternal-mortality.xlsx")
Remember: Three lines: un.search to find it, un.get to fetch it, un.save to send it with its sources.
Transcript
- You need a UN figure for a report, and it has to hold up. Here is how to get it in three lines of Python.
- The UN System Data Commons holds statistics from twenty-six UN System entities. undata puts all of it one import away, in plain words, with nothing to register for.
- Install it once, from the Python Package Index. It works in Jupyter, in Google Colab, or in a plain script.
- Start with what you want to measure, in your own words. un.search lists every matching indicator, with who publishes it, how many places have data, and for which years. This one is the SDG series, from the Global SDG Indicators Database. Copy its ID from the first column.
- Then ask for the numbers. Where an SDG number points to one series, the number is enough. Countries go in the way you would write them in an email. What comes back is an ordinary pandas table, one row per country and year, with the unit and the source on every row.
- Plotted, it tells a story. In Bangladesh, maternal deaths fell from 523 per hundred thousand live births in 2000, to 115 in 2023. In Viet Nam, from 83 to 48.
- Now the line that makes it usable. un.save writes an Excel file, ready to send.
- The data sits on the first sheet. The second holds the sources: the publisher, the link, and a citation you can paste straight into a footnote. It names the agency that measured the figure, not just the website you found it on. A third sheet says how complete the table is.
- Prefer not to write Python at all? The same steps work from a terminal. One command, and the spreadsheet is saved.
- Search. Get. Save. Three lines, and every number arrives with its unit, its year, and its source.
- Install it with pip. Twelve worked examples are on the documentation site. Next: are countries on track for 2030?