Skip to content

pycensus.derived_columns

Canonical derived columns added next to the raw census counts (idempotent: a column that already exists is never replaced).

Names match the simplified template of transitlos.map.col_select. Shares are 0-1 (clipped). Source columns are found by name, bare global name first, then any <source>_<name> twin (non-WorldPop sources before WorldPop): * under18_share, over65_share, foreign_born_share, male_share, female_share = count / population; * university_share, education_basic_or_less_share = count / sum of the education-level counts present (fallback population); * population_density = population / km2 (geometry area, else H3 cell area); * jobs, pop_jobs_total, jobs_density, pop_jobs_density = first jobs source (LODES WAC, BA, StatCan, SII ...) [+ population] (/ km2); * cars_per_household_ratio, zero_vehicle_households_share, transit_commute_share (mobility; only where the census has car ownership / commute mode).

area_km2(df)

Cell / polygon area in km2: H3 id column (cell area at its resolution), else the geometry (equal-area projection).

Parameters:

Name Type Description Default
df

Table with an H3 id column or a geometry.

required

Returns:

Type Description
Optional[ndarray]

Areas in km2, or None.

add_derived_columns(df)

Add the missing canonical derived columns to df in place and return it.

Parameters:

Name Type Description Default
df

Table with global columns.

required

Returns:

Type Description

The same table.

add_gap_columns(df)

Add global columns that the data already holds under local names (see the rules above); idempotent, in place.

Parameters:

Name Type Description Default
df

Table.

required

Returns:

Type Description

The same table.