Querying population types

How to retrieve metadata on population types

The API has many endpoints. One of them returns information about the population types available to users. This guide demonstrates how to get those metadata with census21api.

Getting all types

We can retrieve population type metadata with the CensusAPI.query_population_types() method like so:

from census21api import CensusAPI

api = CensusAPI()
api.query_population_types()
name label description type
0 HH All households Either one usual resident living alone or a gr... microdata
1 HRP All Household Reference Persons A person who serves as a reference point, main... microdata
2 UR All usual residents The main population base for census statistics... microdata
3 UR_CE All usual residents in communal establishments A usual resident who lives in a place that pro... microdata
4 UR_HH All usual residents in households A person who usually lives in England or Wales... microdata

This data frame contains the code, full name, description, and type of every population type exposed through the API.

Note

Note that every population type has type microdata; these are the only population types we can query for tables. The API exposes many more but they are not currently usable by census21api.

Filtering for specific populations

You can also specify to only see some population types when you call the population querist by listing their codes as arguments:

api.query_population_types("UR", "UR_CE", "UR_HH")
name label description type
0 UR All usual residents The main population base for census statistics... microdata
1 UR_CE All usual residents in communal establishments A usual resident who lives in a place that pro... microdata
2 UR_HH All usual residents in households A person who usually lives in England or Wales... microdata