Ejemplo n.º 1
0
    def alter(self, composite_id: str, composite: Dict) -> None:
        overall_rank = self.ranked["overall"][composite_id]
        composites.put_property(composite, self.bmi_rank_overall_var, overall_rank)

        gender: str = self._get_gender(composite_id)
        gender_rank = self.ranked[gender][composite_id]
        composites.put_property(composite, self.bmi_rank_gender_var, gender_rank)
Ejemplo n.º 2
0
 def __call__(self, composite: Dict):
     bmis = [
         bmi for period, bmi in composites.get_all_observations(
             composite, self.annual_bmi_var)
     ]
     mean_bmi = numpy.average(bmis)
     composites.put_property(composite, self.mean_bmi_var, mean_bmi)
Ejemplo n.º 3
0
    def __call__(self, composite: Dict):
        zip_code: str = composites.get_property(composite, self.zip_var)

        city = self.lookups["zipcodes"][zip_code]["City"]
        composites.put_property(composite, self.city_var, city)

        state = self.lookups["zipcodes"][zip_code]["State"]
        composites.put_property(composite, self.state_var, state)
Ejemplo n.º 4
0
 def __call__(self, composite: Dict):
     periods: List[str] = list(composites.get_periods(composite))
     annual_prods = [
         composites.get_observation(composite, period, self.annual_prod_var)
         for period in periods
     ]
     mean_prod = numpy.average(annual_prods)
     composites.put_property(composite, self.mean_prod_var, mean_prod)
Ejemplo n.º 5
0
 def __call__(self, composite: Dict):
     years = sorted(
         [int(year) for year in composites.get_periods(composite)])
     weights = [
         composites.get_observation(composite, str(year),
                                    self.annual_weight_var)
         for year in years
     ]
     slope, intercept, r_value, p_value, std_err = scipy.stats.linregress(
         np.asarray(years), np.asarray(weights))
     composites.put_property(composite, self.weight_slope_var, slope)
     composites.put_property(composite, self.weight_pval_var, p_value)
Ejemplo n.º 6
0
    def emit(self) -> Iterator[Tuple[str, Dict]]:
        for zip_code, transient in self.city_data.items():
            city: Dict = {}
            for period in sorted(composites.get_periods(transient)):
                n_companies = transient[period]["n_companies"]
                tot_employees = transient[period]["tot_employees"]
                tot_revenue = transient[period]["tot_revenue"]

                mean_employees = tot_employees / n_companies
                productivity = tot_revenue / tot_employees

                composites.put_observation(city, period, self.n_company_var,
                                           n_companies)
                composites.put_observation(city, period, self.annual_prod_var,
                                           productivity)
                composites.put_observation(city, period,
                                           self.mean_employee_var,
                                           mean_employees)

            composites.put_property(city, self.target_zip_var,
                                    transient["invariant"]["zip"])
            composites.put_property(city, self.target_city_var,
                                    transient["invariant"]["city"])
            composites.put_property(city, self.target_state_var,
                                    transient["invariant"]["state"])

            yield zip_code, city
Ejemplo n.º 7
0
 def alter(self, composite_id: str, composite: Dict) -> None:
     rank = self.ranked[composite_id]
     composites.put_property(composite, self.bmi_rank_var, rank)