示例#1
0
    def get_health_insurance_data_by_race(self,
                                          use_gcs=False,
                                          gcs_bucket=None):
        if use_gcs:
            for race in RACE:
                # Get cached data from GCS
                state_data = gcs_to_bq_util.load_values_as_json(
                    gcs_bucket, self.get_filename(None, race, False))
                county_data = gcs_to_bq_util.load_values_as_json(
                    gcs_bucket, self.get_filename(None, race, True))

                # Aggregate in Memory
                self.accumulate_acs_data(state_data)
                self.accumulate_acs_data(county_data)
        else:
            for prefix in HEALTH_INSURANCE_BY_RACE_GROUP_PREFIXES:
                # Get ACS data from API
                state_data = self.get_acs_data_from_variables(
                    format_params(prefix,
                                  HEALTH_INSURANCE_BY_RACE_GROUP_SUFFIXES))
                county_sex_data = self.get_acs_data_from_variables(
                    format_params(prefix,
                                  HEALTH_INSURANCE_BY_RACE_GROUP_SUFFIXES,
                                  True))

                # Aggregate in Memory
                self.accumulate_acs_data(state_data)
                self.accumulate_acs_data(county_sex_data)
示例#2
0
 def getData(self, gcs_bucket=None):
     for group in POVERTY_BY_RACE_SEX_AGE_GROUPS:
         for is_county in [True, False]:
             data = None
             if gcs_bucket is None:
                 data = get_acs_data_from_variables(
                     self.base_url, get_params(group, is_county))
             else:
                 data = gcs_to_bq_util.load_values_as_json(
                     gcs_bucket, get_filename(group, is_county))
             self.accumulate_acs_data(data)
示例#3
0
    def get_health_insurance_data_by_sex(self, use_gcs=False, gcs_bucket=None):
        if (use_gcs):  # LOAD JSON BLOBS FROM GCS
            male_state_data = gcs_to_bq_util.load_values_as_json(
                gcs_bucket, self.get_filename(Sex.MALE, None, False))
            female_state_data = gcs_to_bq_util.load_values_as_json(
                gcs_bucket, self.get_filename(Sex.FEMALE, None, False))
            male_county_data = gcs_to_bq_util.load_values_as_json(
                gcs_bucket, self.get_filename(Sex.MALE, None, True))
            female_county_data = gcs_to_bq_util.load_values_as_json(
                gcs_bucket, self.get_filename(Sex.FEMALE, None, True))
        else:  # LOAD DATA FROM ACS (useful for local debug)
            male_state_request_params = format_params(
                HEALTH_INSURANCE_BY_SEX_GROUPS_PREFIX,
                HEALTH_INSURANCE_BY_SEX_MALE_SUFFIXES)
            female_state_request_params = format_params(
                HEALTH_INSURANCE_BY_SEX_GROUPS_PREFIX,
                HEALTH_INSURANCE_BY_SEX_FEMALE_SUFFIXES)
            male_county_request_params = format_params(
                HEALTH_INSURANCE_BY_SEX_GROUPS_PREFIX,
                HEALTH_INSURANCE_BY_SEX_MALE_SUFFIXES, True)
            female_county_request_params = format_params(
                HEALTH_INSURANCE_BY_SEX_GROUPS_PREFIX,
                HEALTH_INSURANCE_BY_SEX_FEMALE_SUFFIXES, True)

            male_state_data = self.get_acs_data_from_variables(
                male_state_request_params)
            female_state_data = self.get_acs_data_from_variables(
                female_state_request_params)
            male_county_data = self.get_acs_data_from_variables(
                male_county_request_params)
            female_county_data = self.get_acs_data_from_variables(
                female_county_request_params)

        # Aggregate and accumulate data in memory
        self.accumulate_acs_data(male_state_data)
        self.accumulate_acs_data(female_state_data)
        self.accumulate_acs_data(male_county_data)
        self.accumulate_acs_data(female_county_data)
示例#4
0
    def getData(self, gcs_bucket=None):

        for is_county in [True, False]:
            if gcs_bucket is not None:  # LOAD JSON BLOBS FROM GCS
                data = gcs_to_bq_util.load_values_as_json(
                    gcs_bucket, self.get_filename(is_county)
                )
            else:  # LOAD DATA FROM ACS (useful for local debug)
                data = get_acs_data_from_variables(
                    self.base_url,
                    get_params(HEALTH_INSURANCE_BY_SEX_GROUPS_PREFIX, False),
                )

            # Aggregate and accumulate data in memory
            self.accumulate_acs_data(data)
示例#5
0
 def getData(self, gcs_bucket=None):
     if gcs_bucket is not None:
         for race in HEALTH_INSURANCE_BY_RACE_GROUP_PREFIXES.values():
             for is_county in [True, False]:
                 # Get cached data from GCS
                 data = gcs_to_bq_util.load_values_as_json(
                     gcs_bucket, self.get_filename(race, is_county)
                 )
                 self.accumulate_acs_data(data)
     else:
         for prefix in HEALTH_INSURANCE_BY_RACE_GROUP_PREFIXES:
             for is_county in [True, False]:
                 data = get_acs_data_from_variables(
                     self.base_url, get_params(prefix, is_county)
                 )
                 self.accumulate_acs_data(data)