Skip to content

pycensus.census.countries.mexico.utils

Small stateless helpers shared by every Mexico census source module.

Technical aspects

Similar to USA.utils, this module provides helper functions for working with Mexico-specific identifiers and naming conventions.

state_abbr(state)

Normalize a state name, abbreviation, or code to its INEGI abbreviation.

Parameters:

Name Type Description Default
state str

State name, abbreviation, or 2-digit code.

required

Returns:

Type Description
str

INEGI state abbreviation (2-4 characters).

Raises:

Type Description
ValueError

If state does not resolve to a known Mexico state.

state_code(state)

Normalize a state name, abbreviation, or code to its INEGI 2-digit code.

Parameters:

Name Type Description Default
state str

State name, abbreviation, or 2-digit code.

required

Returns:

Type Description
str

Two-digit INEGI state code.

Raises:

Type Description
ValueError

If state does not resolve to a known Mexico state.

pick_geoid_column(columns)

Pick the most specific GEOID-like column present.

Parameters:

Name Type Description Default
columns

Candidate column names.

required

Returns:

Type Description
Optional[str]

The best-matching column name, or None if none look like a

Optional[str]

GEOID column.