Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/councilcount/estimates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ def get_councilcount_estimates(acs_year, geo, var_codes="all", boundary_year=Non
# record available years
available_years = sorted(set(int(f.split('_')[-1][:4]) for f in geo_file_names if f.split('_')[-1][:4].isdigit()))

def read_geos(geo, boundary_year=None):
def read_geos(geo, boundary_year=None, var_codes=var_codes):
"""
Internal function to read and wrangle geo files.
"""
Expand Down Expand Up @@ -1215,6 +1215,9 @@ def read_geos(geo, boundary_year=None):
# list of columns for chosen variable(s) if "all" NOT selected
master_col_list = [f'{geo}{add_boundary_year}']

if not isinstance(var_codes, list):
var_codes = [var_codes]

# creating list of desired variables names (for sub-setting final table)
for var_code in var_codes:

Expand Down Expand Up @@ -1252,7 +1255,7 @@ def read_geos(geo, boundary_year=None):
elif (geo == "councildist") and ((boundary_year not in [2013, 2023]) | (boundary_year == None)):
warn("`boundary_year` must be set to 2013 or 2023 when `geo` is 'councildist'. Defaulting to 2023.")
boundary_year = 2023
return read_geos(geo, boundary_year)
return read_geos(geo, boundary_year, var_codes)
elif acs_year not in available_years:
raise ValueError(f"The ACS year {acs_year} could not be found. Available options are:\n" +
", ".join(map(str, available_years)))
Expand All @@ -1261,6 +1264,6 @@ def read_geos(geo, boundary_year=None):
", ".join(geo_names))
elif (geo != "councildist") and (boundary_year is not None):
warn("`boundary_year` is only relevant for `geo = councildist`. Ignoring `boundary_year` input.")
return read_geos(geo)
return read_geos(geo, None, var_codes)
else:
return read_geos(geo, boundary_year)
return read_geos(geo, boundary_year, var_codes)