How to use the census.core 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 / __init__.py View on Github external
def geo(self, fields, geojson_geometry, year=None, resolution='tract', ignore_missing = False, **kwargs):
        if year is None:
            year = self.default_year
            
        fields = census.core.list_or_str(fields)

        as_acs = kwargs.get('as_acs', False)
        if as_acs:
            acs_fields = self._cross(fields)
            for field in acs_fields:
                if self._field_type(field, year) is not int:
                    raise ValueError('{} is not a variable that can be aggregated your geography'.format(field))
        else:
            for field in fields:
                if self._field_type(field, year) is not int:
                    raise ValueError('{} is not a variable that can be aggregated your geography'.format(field))


        resolutions = {'tract': self.geo_tract,
                       'blockgroup': self.geo_blockgroup}