Skip to content

pycensus.global_equivalents

Global-schema equivalents of differently named census columns (reference/global_equivalents.json).

add_global_equivalents(df) adds, for every local column present, the global-schema column that means the same thing (the local value repeated) -- unless the global column already exists. A column whose local name already equals the global name is NOT handled here (the pipelines rename it to the bare global name, so there is only one column).

equivalents() cached

{local column: global feature name}.

originals() cached

{global-named column: twin that keeps the census column's original meaning} (see originals in the JSON).

latest_equivalents(columns)

{global feature: local column} for the period-carrying columns (latest election per scope, latest-period housing columns).

Patterns come from latest_patterns in the JSON: ordered regexes per global name; the first regex with matches wins and the latest period among its matches is chosen (an un-suffixed column = current period).

Parameters:

Name Type Description Default
columns

Column names.

required

add_global_equivalents(df)

df (pandas / geopandas) with the global-named twin of every equivalent local column present (values copied), plus the period-free global names (elec_national_left_share, rent_per_m2_mean, ...) of the LATEST period of each local family.

Parameters:

Name Type Description Default
df

Table.

required

Returns:

Type Description

The same table.