City Population Annual Timeseries (UN Statistics Division)

3,271
Updated:
Files:4
Size:12 MB
Formats:csv

City population yearly timeseries for female and male, and for both sexes, collected by the United Nations Statistics Division and published by UNData in 22 Dec 2014 Next update in UNdata: Jun 2015 (est.) Periodicity: biannual. Contains two datasets in CSV format: unsd-citypopulation-year-both.csv Size: 2.4 MB unsd-citypopulation-year-fm.csv File size: 3.7 MB Final 222 lines in both datasets contain original notes.

Part of these Data Solutions

  • Global Country & Region Reference Data Solution

    Authoritative country codes, regions and location reference data to power your location-based solutions.

    Explore →
  • Logistics Data Solution

    Comprehensive reference for shipping codes, container standards and more.

    Explore →

API Access

Access dataset files directly from scripts, code, or AI agents.

Browse dataset files
Dataset Files

Each file has a stable URL (r-link) that you can use directly in scripts, apps, or AI agents. These URLs are permanent and safe to hardcode.

/core/population-city/
https://datahub.io/core/population-city/_r/-/.gitignore
https://datahub.io/core/population-city/_r/-/ATTRIBUTION.txt
https://datahub.io/core/population-city/_r/-/README.md
https://datahub.io/core/population-city/_r/-/UPDATE_SCRIPT_MAINTENANCE_REPORT.md
https://datahub.io/core/population-city/_r/-/data/unsd-citypopulation-year-both-footnotes.csv
https://datahub.io/core/population-city/_r/-/data/unsd-citypopulation-year-both.csv
https://datahub.io/core/population-city/_r/-/data/unsd-citypopulation-year-fm-footnotes.csv
https://datahub.io/core/population-city/_r/-/data/unsd-citypopulation-year-fm.csv
https://datahub.io/core/population-city/_r/-/datapackage.json
Key Files

Start with these files — they give you everything you need to understand and access the dataset.

datapackage.json— metadata & schema
https://datahub.io/core/population-city/_r/-/datapackage.json
README.md— documentation
https://datahub.io/core/population-city/_r/-/README.md
Typical Usage
  1. 1. Fetch datapackage.json to inspect schema and resources
  2. 2. Download data resources listed in datapackage.json
  3. 3. Read README.md for full context

Data Files

Explore with AI

unsd-citypopulation-year-both

unsd-citypopulation-year-both-footnotes

unsd-citypopulation-year-fm

unsd-citypopulation-year-fm-footnotes


About this dataset

badge

City population

Population of cities by year, for both sexes and for females and males, from the UN Statistics Division (UNSD Demographic Statistics). The figures come from national statistical offices through the UN Demographic Yearbook.

Column definitions and types are in datapackage.json.

Data

  • data/unsd-citypopulation-year-both.csv has the figures for both sexes.
  • data/unsd-citypopulation-year-fm.csv has the figures for females and males, one row each.
  • Each data file has a footnotes file next to it: data/unsd-citypopulation-year-both-footnotes.csv and data/unsd-citypopulation-year-fm-footnotes.csv.

Columns of the two data files:

ColumnMeaning
Country or AreaCountry or area, as named by the UN, for example Åland Islands
YearReference year of the figure
AreaPart of the city covered, for example Total
SexBoth Sexes in the first file; Female or Male in the second
CityCity name as given by the UN, often in capitals, for example MARIEHAMN
City typeCity proper or Urban agglomeration
Record TypeKind of record, for example Estimate - de jure or Census - de facto - complete tabulation
ReliabilityFor example Final figure, complete or Provisional figure
Source YearYear of the source the figure was taken from
ValuePopulation. A few figures have a decimal part, for example 11911.5
Value FootnotesFootnote numbers for the figure, separated by commas (for example 4,5). Empty when there is none

Columns of the footnotes files: footnoteSeqID (the footnote number) and Footnote (its text).

Known limitations

  • The same city can have several rows for the same year, from different sources. They differ in Record Type, Reliability or Source Year. Choose one before you count or compare.
  • A city can be listed both as City proper and as Urban agglomeration. The agglomeration normally includes the city proper, so adding the two counts people twice.
  • Footnote numbers belong to one file. Number 4 in the first file does not mean the same as number 4 in the second. The UN can also number its footnotes differently each time the data is exported, so a number can change when the data is rebuilt. Always use the footnotes file that was committed with the data file.
  • Value Footnotes can hold several numbers in one cell (4,5). Split it on commas before you look the numbers up.
  • All fields are in quotes and lines end with a carriage return and a line feed (\r\n), as in the UN export. Any CSV reader handles this.
  • With pandas: pd.read_csv("data/unsd-citypopulation-year-both.csv"). Year, Source Year and Value are numbers.

Data sources

  • UN data: UNSD Demographic Statistics, table "City population by sex, city and city type". It provides all figures and footnotes. Licence: the UN data conditions of use. They say all data and metadata may be copied freely, duplicated and further distributed, provided UN data is cited as the reference.

Changes made to the source data: the UN export has a table of footnotes at its end. The update script moves that table into its own footnotes file. Nothing else in the figures is changed.

Not endorsed by, or affiliated with, the United Nations.

Preparation

You need Python 3.12 or greater. To rebuild the data from the repository root:

pip install -r scripts/requirements.txt
python scripts/process.py

The script downloads the two tables from UN data, moves the footnotes into their own files and records the date of the last UN update in last_updated in datapackage.json. It stops with an error if the UN site does not return the files it expects.

A GitHub workflow runs the script on the first day of January, March, May, July, September and November, and when started by hand. It commits data/ and datapackage.json if they changed.

The data is also published on datahub.io.

License

The UN data conditions of use allow the figures and footnotes to be copied, duplicated and further distributed free of charge, as long as UN data is cited as the reference. See ATTRIBUTION.txt.

The maintainers offer this package under the Open Data Commons Public Domain Dedication and License (PDDL) 1.0. That applies to their own work: the update script, the column definitions and the file layout. It does not replace the UN conditions of use.