Querying feature item categories

How to query metadata on a particular feature item

Some of the features (area types and dimensions) for a population type may be unfamiliar or difficult to understand. This guide shows you how to get metadata on an item from a feature.

Querying a dimension’s categorisations

To do this for a given dimension, pass your population type and item to the CensusAPI.query_categories() method.

from census21api import CensusAPI

api = CensusAPI()

population_type = "UR_HH"
feature = "dimensions"
item = "health_in_general"

api.query_categories(population_type, feature, item)
id label dimension population_type
0 -8 Does not apply health_in_general UR_HH
1 1 Very good health health_in_general UR_HH
2 2 Good health health_in_general UR_HH
3 3 Fair health health_in_general UR_HH
4 4 Bad health health_in_general UR_HH
5 5 Very bad health health_in_general UR_HH

Querying an area type’s areas

You can use the same method to query category metadata for area types:

feature = "area-types"
item = "msoa"

api.query_categories(population_type, feature, item)
id label area_type population_type
0 E02000001 City of London 001 msoa UR_HH
1 E02000002 Barking and Dagenham 001 msoa UR_HH
2 E02000003 Barking and Dagenham 002 msoa UR_HH
3 E02000004 Barking and Dagenham 003 msoa UR_HH
4 E02000005 Barking and Dagenham 004 msoa UR_HH
... ... ... ... ...
7259 W02000424 Wrexham 021 msoa UR_HH
7260 W02000425 Wrexham 022 msoa UR_HH
7261 W02000426 Wrexham 023 msoa UR_HH
7262 W02000427 Neath Port Talbot 021 msoa UR_HH
7263 W02000428 Swansea 032 msoa UR_HH

7264 rows × 4 columns