How to use the census.math.moe_of_sum function in census

To help you get started, we’ve selected a few census examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github datamade / census_area / census_area / View on Github external
def _aggregate(self, fields, features, year, ignore_missing):
        aggregated_features = collections.defaultdict(list)
        for _, feature in features:
            if ignore_missing and None in feature.values():
            for field in fields:

        collapsed = {}
        for field in fields:
            if field.endswith('E'):
                agg = sum(aggregated_features[field])
            elif field.endswith('M'):
                e_field = field[:-1] + 'E'
                agg = census.math.moe_of_sum(aggregated_features[e_field],
                raise ValueError("Don't know how to aggregate this variable {}".format(feature))

            collapsed[field] = agg

        return collapsed