utils module¶
Some simple utilities for handling data interaction.
- ziptool.utils.cast_fips_code(state_fips_code: Union[str, int]) str ¶
FIPS codes are technically two-digit strings representing a number between 0 and 99, e.g., “01” and “44”. But it is very common that people pass them as integers. This guarantees they always appear as two-digit strings.
- Parameters
state_fips_code – A FIPS code as either a string or an int
- Returns
The appropriately styled version of the code
- ziptool.utils.cast_zipcode(zipcode: Union[str, int]) str ¶
ZIP codes are five-digit strings, but it is very common that people pass them as integers. This guarantees that they always appear as five-digit strings
- Parameters
zipcode – A ZIP code
- Returns
The appropriately styled version of the code
- ziptool.utils.get_fips_code_from_abbr(state: str) str ¶
Given a state postal abbreviation, e.g., “RI”, return its FIPS code, e.g., “44”
- Parameters
state – The abbreviation of the state
- Returns
The FIPS code of the state
Raises:
- ziptool.utils.puma_shapefile_name(state_fips_code: Union[str, int]) str ¶
Return the expected filename of the PUMA shapefile. Note that this assumes a 2019 filename.
- Parameters
code – The FIPS code for the state of interest
- Returns
The expected filename
- ziptool.utils.tract_shapefile_name(state_fips_code: Union[str, int]) str ¶
Return the expected filename of the tract shapefile. Note that this assumes a 2019 filename.
- Parameters
code – The FIPS code for the state of interest
- Returns
The expected filename