Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Minimum Example: Fetching a Dimension Table

This notebook shows the shortest path to fetching a Census group and displaying it as a dimension table.

from morpc_census import Endpoint, CensusAPI, DimensionTable

1. Build an Endpoint

An Endpoint pairs a survey name with a vintage year.

ep = Endpoint('dec/pl', 2020)

2. Fetch the data

CensusAPI takes an endpoint, a scope, and a group code. Here we fetch B02001 (Race) for the 15-county MORPC region.

api = CensusAPI(ep, 'region15', group='P1')
api.long
Loading...

3. Display as a DimensionTable

DimensionTable parses the !!-delimited variable labels into named columns and pivots to a wide layout. B02001 has two label levels: a grand total and a race category.

dim = DimensionTable(api.long)
dim.wide()
Loading...