Skip to content

pycensus.census.countries.israel.utils

Small stateless helpers shared by every Israel census source module.

Technical aspects

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

district_code(district)

Normalize a district name, abbreviation, or code to its CBS code.

Parameters:

Name Type Description Default
district str

District name, abbreviation, Hebrew name, or 1-digit code.

required

Returns:

Type Description
str

One-digit CBS district code.

Raises:

Type Description
ValueError

If district does not resolve to a known Israel district.

district_abbr(district)

Normalize a district name or code to its abbreviation.

Parameters:

Name Type Description Default
district str

District name or 1-digit code.

required

Returns:

Type Description
str

Abbreviation for the district.

Raises:

Type Description
ValueError

If district does not resolve to a known Israel district.

subdistrict_code(subdistrict)

Normalize a sub-district name or code to its CBS code.

Note: This is a partial implementation. In a real implementation, this would require a comprehensive mapping of all sub-districts.

Parameters:

Name Type Description Default
subdistrict str

Sub-district name or 2-digit code (district + sub-district).

required

Returns:

Type Description
str

Two-digit CBS sub-district code.

Raises:

Type Description
ValueError

If subdistrict does not resolve to a known Israel sub-district.

locality_code(locality)

Normalize a locality name or code to its CBS SETL_CODE/CR_LAMAS code.

A numeric code (int or a digit-only str) is passed through unchanged (as a string). A name is resolved via a real, live query against :data:pycensus.israel.constants.CENSUS_SETL_2022_URL (matching its ENG_NAME field case-insensitively) -- no hardcoded locality-name table, since CBS's own locality attribute layer is already the authoritative real source for this.

Parameters:

Name Type Description Default
locality

Locality name, or numeric code (int or str).

required

Returns:

Type Description
str

CBS locality code, as a string.

Raises:

Type Description
ValueError

If locality does not resolve to a known Israel locality.

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.