How to use the censusdata.censusvar function in CensusData

To help you get started, we’ve selected a few CensusData 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 jtleider / censusdata / test / test_variable_info.py View on Github external
def test_censusvar_sf1(self):
		self.assertEqual(censusdata.censusvar('sf1', 2010, ['P001001']),
			{'P001001': ['TOTAL POPULATION', 'Total', '']})
github jtleider / censusdata / test / test_variable_info.py View on Github external
def test_censusvar_acs1(self):
		expected = {'S0101_C02_001E': ['AGE AND SEX', 'Male!!Estimate!!Total population', 'int'],
			'DP03_0021PE': ['SELECTED ECONOMIC CHARACTERISTICS', 'Percent!!COMMUTING TO WORK!!Workers 16 years and over!!Public transportation (excluding taxicab)', 'float'],
			'CP02_2012_030E': ['COMPARATIVE SOCIAL CHARACTERISTICS IN THE UNITED STATES', '2012 Estimate!!MARITAL STATUS!!Females 15 years and over', 'int']}
		self.assertEqual(censusdata.censusvar('acs1', 2015, ['S0101_C02_001E', 'DP03_0021PE', 'CP02_2012_030E']), expected)
		expected = {'S0101_C02_001E': ['', 'Male!!Estimate!!Total population', 'int'],
			'DP03_0021PE': ['', 'Percent!!COMMUTING TO WORK!!Workers 16 years and over!!Public transportation (excluding taxicab)', 'int'],
			'CP02_2012_030E': ['', '2012 Estimate!!MARITAL STATUS!!Females 15 years and over', 'int']}
		self.assertEqual(censusdata.censusvar('acs1', 2016, ['S0101_C02_001E', 'DP03_0021PE', 'CP02_2012_030E']), expected)
		expected = {'S0101_C02_001E': ['AGE AND SEX', 'Percent!!Estimate!!Total population', 'int'],
			'DP03_0021PE': ['SELECTED ECONOMIC CHARACTERISTICS', 'Percent!!COMMUTING TO WORK!!Workers 16 years and over!!Public transportation (excluding taxicab)', 'float'],
			'CP02_2013_030E': ['COMPARATIVE SOCIAL CHARACTERISTICS IN THE UNITED STATES', '2013 Estimate!!MARITAL STATUS!!Females 15 years and over', 'int']}
		self.assertEqual(censusdata.censusvar('acs1', 2017, ['S0101_C02_001E', 'DP03_0021PE', 'CP02_2013_030E']), expected)
		expected = {'S0101_C02_001E': ['AGE AND SEX', 'Estimate!!Percent!!Total population', 'int'],
			'DP03_0021PE': ['SELECTED ECONOMIC CHARACTERISTICS', 'Percent Estimate!!COMMUTING TO WORK!!Workers 16 years and over!!Public transportation (excluding taxicab)', 'float'],
			'CP02_2014_030E': ['COMPARATIVE SOCIAL CHARACTERISTICS IN THE UNITED STATES', '2014 Estimate!!MARITAL STATUS!!Females 15 years and over', 'int']}
		self.assertEqual(censusdata.censusvar('acs1', 2018, ['S0101_C02_001E', 'DP03_0021PE', 'CP02_2014_030E']), expected)
github jtleider / censusdata / test / test_variable_info.py View on Github external
def test_censusvar_acsse(self):
		for year in range(2014, 2017+1):
			concept = 'PRESENCE OF A COMPUTER AND TYPE OF INTERNET SUBSCRIPTION IN HOUSEHOLD'
			expected = {'K202801_006E': [concept, 'Estimate!!Total!!No computer', 'int']}
			self.assertEqual(censusdata.censusvar('acsse', year, ['K202801_006E']), expected)
github jtleider / censusdata / test / test_variable_info.py View on Github external
def test_censusvar_acs1(self):
		expected = {'S0101_C02_001E': ['AGE AND SEX', 'Male!!Estimate!!Total population', 'int'],
			'DP03_0021PE': ['SELECTED ECONOMIC CHARACTERISTICS', 'Percent!!COMMUTING TO WORK!!Workers 16 years and over!!Public transportation (excluding taxicab)', 'float'],
			'CP02_2012_030E': ['COMPARATIVE SOCIAL CHARACTERISTICS IN THE UNITED STATES', '2012 Estimate!!MARITAL STATUS!!Females 15 years and over', 'int']}
		self.assertEqual(censusdata.censusvar('acs1', 2015, ['S0101_C02_001E', 'DP03_0021PE', 'CP02_2012_030E']), expected)
		expected = {'S0101_C02_001E': ['', 'Male!!Estimate!!Total population', 'int'],
			'DP03_0021PE': ['', 'Percent!!COMMUTING TO WORK!!Workers 16 years and over!!Public transportation (excluding taxicab)', 'int'],
			'CP02_2012_030E': ['', '2012 Estimate!!MARITAL STATUS!!Females 15 years and over', 'int']}
		self.assertEqual(censusdata.censusvar('acs1', 2016, ['S0101_C02_001E', 'DP03_0021PE', 'CP02_2012_030E']), expected)
		expected = {'S0101_C02_001E': ['AGE AND SEX', 'Percent!!Estimate!!Total population', 'int'],
			'DP03_0021PE': ['SELECTED ECONOMIC CHARACTERISTICS', 'Percent!!COMMUTING TO WORK!!Workers 16 years and over!!Public transportation (excluding taxicab)', 'float'],
			'CP02_2013_030E': ['COMPARATIVE SOCIAL CHARACTERISTICS IN THE UNITED STATES', '2013 Estimate!!MARITAL STATUS!!Females 15 years and over', 'int']}
		self.assertEqual(censusdata.censusvar('acs1', 2017, ['S0101_C02_001E', 'DP03_0021PE', 'CP02_2013_030E']), expected)
		expected = {'S0101_C02_001E': ['AGE AND SEX', 'Estimate!!Percent!!Total population', 'int'],
			'DP03_0021PE': ['SELECTED ECONOMIC CHARACTERISTICS', 'Percent Estimate!!COMMUTING TO WORK!!Workers 16 years and over!!Public transportation (excluding taxicab)', 'float'],
			'CP02_2014_030E': ['COMPARATIVE SOCIAL CHARACTERISTICS IN THE UNITED STATES', '2014 Estimate!!MARITAL STATUS!!Females 15 years and over', 'int']}
		self.assertEqual(censusdata.censusvar('acs1', 2018, ['S0101_C02_001E', 'DP03_0021PE', 'CP02_2014_030E']), expected)
github jtleider / censusdata / test / test_variable_info.py View on Github external
expected = {'S0101_C02_001E': ['AGE AND SEX', 'Male!!Estimate!!Total population', 'int'],
			'DP03_0021PE': ['SELECTED ECONOMIC CHARACTERISTICS', 'Percent!!COMMUTING TO WORK!!Workers 16 years and over!!Public transportation (excluding taxicab)', 'float'],
			'CP02_2012_030E': ['COMPARATIVE SOCIAL CHARACTERISTICS IN THE UNITED STATES', '2012 Estimate!!MARITAL STATUS!!Females 15 years and over', 'int']}
		self.assertEqual(censusdata.censusvar('acs1', 2015, ['S0101_C02_001E', 'DP03_0021PE', 'CP02_2012_030E']), expected)
		expected = {'S0101_C02_001E': ['', 'Male!!Estimate!!Total population', 'int'],
			'DP03_0021PE': ['', 'Percent!!COMMUTING TO WORK!!Workers 16 years and over!!Public transportation (excluding taxicab)', 'int'],
			'CP02_2012_030E': ['', '2012 Estimate!!MARITAL STATUS!!Females 15 years and over', 'int']}
		self.assertEqual(censusdata.censusvar('acs1', 2016, ['S0101_C02_001E', 'DP03_0021PE', 'CP02_2012_030E']), expected)
		expected = {'S0101_C02_001E': ['AGE AND SEX', 'Percent!!Estimate!!Total population', 'int'],
			'DP03_0021PE': ['SELECTED ECONOMIC CHARACTERISTICS', 'Percent!!COMMUTING TO WORK!!Workers 16 years and over!!Public transportation (excluding taxicab)', 'float'],
			'CP02_2013_030E': ['COMPARATIVE SOCIAL CHARACTERISTICS IN THE UNITED STATES', '2013 Estimate!!MARITAL STATUS!!Females 15 years and over', 'int']}
		self.assertEqual(censusdata.censusvar('acs1', 2017, ['S0101_C02_001E', 'DP03_0021PE', 'CP02_2013_030E']), expected)
		expected = {'S0101_C02_001E': ['AGE AND SEX', 'Estimate!!Percent!!Total population', 'int'],
			'DP03_0021PE': ['SELECTED ECONOMIC CHARACTERISTICS', 'Percent Estimate!!COMMUTING TO WORK!!Workers 16 years and over!!Public transportation (excluding taxicab)', 'float'],
			'CP02_2014_030E': ['COMPARATIVE SOCIAL CHARACTERISTICS IN THE UNITED STATES', '2014 Estimate!!MARITAL STATUS!!Females 15 years and over', 'int']}
		self.assertEqual(censusdata.censusvar('acs1', 2018, ['S0101_C02_001E', 'DP03_0021PE', 'CP02_2014_030E']), expected)
github jtleider / censusdata / test / test_variable_info.py View on Github external
def test_censusvar_acs5(self):
		expected = {'B01001_001E': ['B01001.  Sex by Age', 'Total:', 'int'],
			'B01002_001E': ['B01002.  Median Age by Sex', 'Median age --!!Total:', 'int'],
			'B19013_001E': ['B19013.  Median Household Income',
				'Median household income in the past 12 months (in 2009 inflation-adjusted dollars)', 'int']}
		self.assertEqual(censusdata.censusvar('acs5', 2009, ['B01001_001E', 'B01002_001E', 'B19013_001E']), expected)
		for year in range(2010, 2018+1):
			concepts = ['SEX BY AGE', 'MEDIAN AGE BY SEX', 'MEDIAN HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN {0} INFLATION-ADJUSTED DOLLARS)'.format(year)]
			types = ['int', 'float', 'int']
			if year == 2016: types = ['', 'int', 'int']
			if year == 2017: types = ['', 'float', 'int']
			inflation = 'inflation'
			if year == 2014 or year == 2015: inflation = 'Inflation'
			median_age_label = 'Estimate!!Median age!!Total'
			if year == 2018: median_age_label = 'Estimate!!Median age --!!Total'
			expected = {'B01001_001E': [concepts[0], 'Estimate!!Total', types[0]],
				'B01002_001E': [concepts[1], median_age_label, types[1]],
				'B19013_001E': [concepts[2],
					'Estimate!!Median household income in the past 12 months (in {0} {1}-adjusted dollars)'.format(year, inflation), types[2]]}
			self.assertEqual(censusdata.censusvar('acs5', year, ['B01001_001E', 'B01002_001E', 'B19013_001E']), expected)
github jtleider / censusdata / test / test_variable_info.py View on Github external
def test_unknownvar(self):
		self.assertRaises(ValueError, censusdata.censusvar, 'acs5', 2015, ['B19013_010E'])
github jtleider / censusdata / test / test_variable_info.py View on Github external
'Median household income in the past 12 months (in 2009 inflation-adjusted dollars)', 'int']}
		self.assertEqual(censusdata.censusvar('acs5', 2009, ['B01001_001E', 'B01002_001E', 'B19013_001E']), expected)
		for year in range(2010, 2018+1):
			concepts = ['SEX BY AGE', 'MEDIAN AGE BY SEX', 'MEDIAN HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN {0} INFLATION-ADJUSTED DOLLARS)'.format(year)]
			types = ['int', 'float', 'int']
			if year == 2016: types = ['', 'int', 'int']
			if year == 2017: types = ['', 'float', 'int']
			inflation = 'inflation'
			if year == 2014 or year == 2015: inflation = 'Inflation'
			median_age_label = 'Estimate!!Median age!!Total'
			if year == 2018: median_age_label = 'Estimate!!Median age --!!Total'
			expected = {'B01001_001E': [concepts[0], 'Estimate!!Total', types[0]],
				'B01002_001E': [concepts[1], median_age_label, types[1]],
				'B19013_001E': [concepts[2],
					'Estimate!!Median household income in the past 12 months (in {0} {1}-adjusted dollars)'.format(year, inflation), types[2]]}
			self.assertEqual(censusdata.censusvar('acs5', year, ['B01001_001E', 'B01002_001E', 'B19013_001E']), expected)
github jtleider / censusdata / test / test_variable_info.py View on Github external
def test_censusvar_acs3(self):
		for year in range(2013, 2013+1):
			expected = {'B19013_001E': ['B19013.  Median Household Income'.format(year),
				'Median household income in the past 12 months (in {0} inflation-adjusted dollars)'.format(year), 'int']}
			self.assertEqual(censusdata.censusvar('acs3', year, ['B19013_001E']), expected)

CensusData

Download data from U.S. Census API

MIT
Latest version published 2 years ago

Package Health Score

45 / 100
Full package analysis

Similar packages