Countries, regions and groups¶
undata ships the UN Statistics Division’s M49 standard: 248 countries and areas with
their official names, M49 regions and sub-regions, and the current UN lists of least
developed countries (LDCs), landlocked developing countries (LLDCs) and small island
developing States (SIDS). Places the platform holds outside M49 are in no list, region
or group, and can be reached only by platform code (such as country/XKS).
- countries(region=None)[source]¶
List countries and areas, all of them or those in one region or group.
The list is the UN’s M49 standard, with official UN names.
- Parameters:
region (str | None) – A region or group such as
"Western Africa","Asia"or"SIDS". Leave it out for every country and area.- Returns:
A table with
country,iso3,m49,region,sub_region, andldc,lldcandsidsas true or false. Sorted by name.- Return type:
Example
>>> import undata as un >>> len(un.countries("LDCs")) > 40 True
- regions()[source]¶
List every region and UN group you can use wherever undata asks for countries.
- Returns:
A table with
region,kind(region or group),code(the M49 code or group key),countries(how many), andpublished_total(whether the platform holds a figure published for the region itself, forundata.totals()).- Return type:
Example
>>> import undata as un >>> "Southern Asia" in set(un.regions()["region"]) True
Resolving names yourself¶
- resolve(name)[source]¶
Return the country, region or group a name refers to.
- Parameters:
name (str) – A UN name or common name, an ISO3 or M49 code, a region or group name, or a platform code such as
country/XKSfor a place outside M49.- Raises:
PlaceNotFoundError – The name matches nothing. The error lists close matches.
AmbiguousPlaceError – The name is part of several names, such as “Korea”.
Example
>>> import undata as un >>> un.places.resolve("Vietnam").name 'Viet Nam' >>> un.places.resolve("LDCs").kind 'group'
- expand(places)[source]¶
Resolve names to countries, expanding each region or group into its countries.
Order is kept and duplicates are dropped, so
["Nepal", "Southern Asia"]lists Nepal once.
- class Place(id, name, kind, members=())[source]¶
A country, a region, a UN group, or an area outside M49.
- id¶
The platform’s identifier:
country/BGDfor a country, or the id of the figure published for a region (m49/...when none is published).- Type:
- kind¶
"country","region","group", or"area"for a place outside M49 asked for by its platform code.- Type:
Literal[‘country’, ‘region’, ‘group’, ‘area’]