Skip to content

Commit

Permalink
force print with B code not C code
Browse files Browse the repository at this point in the history
  • Loading branch information
benhammondmusic committed May 17, 2024
1 parent a3b2bd0 commit b15231e
Show file tree
Hide file tree
Showing 22 changed files with 1,307,126 additions and 6,769 deletions.
5 changes: 2 additions & 3 deletions airflow/dags/acs_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

# CACHE ACS SOURCE INTO TMP JSON IN BUCKETS


# acs_condition_gcs_payload_2012 = util.generate_gcs_payload(_ACS_WORKFLOW_ID, year='2012')
# acs_condition_gcs_operator_2012 = util.create_gcs_ingest_operator(
# 'acs_condition_to_gcs_2012', acs_condition_gcs_payload_2012, data_ingestion_dag
Expand Down Expand Up @@ -132,7 +131,7 @@
# "acs_condition_to_bq_2022", acs_condition_bq_payload_2022, data_ingestion_dag
# )

# EXPORT FROM BQ TO BUCKETS
# # EXPORT FROM BQ TO BUCKETS
# acs_condition_exporter_payload_race = {
# 'dataset_name': _ACS_DATASET_NAME,
# 'demographic': "by_race",
Expand Down Expand Up @@ -172,7 +171,7 @@
# >> acs_condition_gcs_operator_2019
# >> acs_condition_gcs_operator_2020
# >> acs_condition_gcs_operator_2021
# >>
# >> acs_condition_gcs_operator_2022
acs_condition_gcs_operator_2022
# PROCESSING STEP
# >> acs_condition_bq_operator_2012
Expand Down
58 changes: 41 additions & 17 deletions python/datasources/acs_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@
}

EDUCATION_BY_RACE_SEX_AGE_GROUP_PREFIXES = {
'C15002A': Race.WHITE.value,
'C15002B': Race.BLACK.value,
'C15002C': Race.AIAN.value,
'C15002D': Race.ASIAN.value,
'C15002E': Race.NHPI.value,
'C15002F': Race.OTHER_STANDARD.value,
'C15002G': Race.MULTI.value,
'C15002I': Race.HISP.value,
'B15002A': Race.WHITE.value,
'B15002B': Race.BLACK.value,
'B15002C': Race.AIAN.value,
'B15002D': Race.ASIAN.value,
'B15002E': Race.NHPI.value,
'B15002F': Race.OTHER_STANDARD.value,
'B15002G': Race.MULTI.value,
'B15002I': Race.HISP.value,
}


Expand All @@ -202,6 +202,7 @@ class AcsItem:
prefix_map: A dictionary mapping the acs prefix to its corresponding race.
concept_map: A dictionary mapping to its corresponding census concept.
sex_age_prefix: The acs prefix representing the sex and age data.
sex_age_concept: The census concept representing the sex and age data.
has_condition_key_list: List[str] Keys in acs metadata representing the tracker's "yes"
state for this condition. For example, it would be the
key represting that someone has poverty, or does not
Expand Down Expand Up @@ -249,7 +250,7 @@ def __init__(
POVERTY_BY_SEX_AGE_CONCEPT_CAPS = 'POVERTY STATUS IN THE PAST 12 MONTHS BY SEX BY AGE'
POVERTY_BY_SEX_AGE_CONCEPT_TITLE = 'Poverty Status in the Past 12 Months by Sex by Age'

EDUCATION_BY_SEX_AGE_GROUPS_PREFIX = 'C15002'
EDUCATION_BY_SEX_AGE_GROUPS_PREFIX = 'B15002'
EDUCATION_BY_SEX_AGE_CONCEPT_CAPS = 'SEX BY EDUCATIONAL ATTAINMENT FOR THE POPULATION 25 YEARS AND OVER'
EDUCATION_BY_SEX_AGE_CONCEPT_TITLE = 'Sex by Educational Attainment for the Population 25 Years and Over'

Expand All @@ -268,12 +269,33 @@ def __init__(
NOT_IN_POVERTY_KEY = 'Income in the past 12 months at or above poverty level'
POVERTY_KEY = 'Income in the past 12 months below poverty level'

# HAS_HIGH_SCHOOL_KEY_LIST = [
# 'High school graduate (includes equivalency)',
# "Some college or associate's degree",
# "Bachelor's degree or higher",
# ]
# NOT_HIGH_SCHOOL_KEY_LIST = ['Less than high school diploma']

HAS_HIGH_SCHOOL_KEY_LIST = [
'High school graduate (includes equivalency)',
"Some college or associate's degree",
"Bachelor's degree or higher",
"Doctorate degree",
"Master's degree",
"Professional school degree",
"Bachelor's degree",
"Associate's degree",
"Some college, 1 or more years, no degree",
"High school graduate (includes equivalency)",
]

NOT_HIGH_SCHOOL_KEY_LIST = [
"12th grade, no diploma",
"11th grade",
"10th grade",
"9th grade",
"7th and 8th grade",
"5th and 6th grade",
"Nursery to 4th grade",
"No schooling completed",
]
NOT_HIGH_SCHOOL_KEY_LIST = ['Less than high school diploma']

HEALTH_INSURANCE_MEASURE = 'health_insurance'
POVERTY_MEASURE = 'poverty'
Expand Down Expand Up @@ -647,13 +669,15 @@ def generate_df_for_concept(self, measure, acs_item, df, demo, geo, concept, var
elif measure == EDUCATION_MEASURE:
group_cols = [std_col.SEX_COL, tmp_amount_key]

print("concept", concept)

group_vars = get_vars_for_group(concept, var_map, len(group_cols))

# print("---group_cols")
# print(group_cols)
print("---group_cols")
print(group_cols)

# print("---group_vars")
# print(group_vars)
print("---group_vars")
print(group_vars)

# Creates a df with different rows for the amount of people
# in a demographic group with and without the condition
Expand Down
18 changes: 16 additions & 2 deletions python/ingestion/census.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,18 @@ def parse_acs_metadata(acs_metadata, groups):
groups: The list of group ids to include."""
output_vars = {}
for variable_id, metadata in acs_metadata["variables"].items():

group = metadata.get("group")

# print("group", group)

if group in groups and metadata["label"].startswith("Estimate!!Total"):
print("variable_id", variable_id)
print("metadata", metadata)
output_vars[variable_id] = metadata

# print("output_vars", output_vars)

return output_vars


Expand Down Expand Up @@ -136,13 +145,18 @@ def get_vars_for_group(group_concept, var_map, num_breakdowns):
# print("group:", group)
# print("metadata:", metadata)
# print("<><><>")
# if group_concept == "Sex by Educational Attainment for the Population 25 Years and Over":
# print("metadata.get('concept')", metadata.get("concept"))
# print("group_concept", group_concept)
# print("+++")

if metadata.get("concept") == group_concept:
# print("group", group)
# print("metadata.get('concept')", metadata.get("concept"))

print("MATCH" + group_concept)

# TODO switch to use explicit prefix to handle median, etc
parts = metadata["label"].split("!!")

# If length is greater than (2 + num_breakdowns), it means it's a
# sub-category, which we don't need to include. If the length is
# less than (2 + num_breakdowns), it means it's a combination of
Expand Down
Binary file removed python/tests/data/acs_condition/.DS_Store
Binary file not shown.

0 comments on commit b15231e

Please sign in to comment.