How to use the censusdata.printtable 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_printtable(self):
		testtable = censusdata.censustable('acs5', 2015, 'B19013')
		printedtable = io.StringIO()
		sys.stdout = printedtable
		censusdata.printtable(testtable)
		sys.stdout = sys.__stdout__
		self.assertEqual(printedtable.getvalue(), textwrap.dedent(
			'''\
			Variable     | Table                          | Label                                                    | Type 
			-------------------------------------------------------------------------------------------------------------------
			B19013_001E  | B19013. Median Household Incom | Median household income in the past 12 months (in 2015 I | int  
			-------------------------------------------------------------------------------------------------------------------
			'''))
		printedtable.close()
		printedtable = io.StringIO()
		sys.stdout = printedtable
		censusdata.printtable(testtable, moe=True)
		sys.stdout = sys.__stdout__
		self.assertEqual(printedtable.getvalue(), textwrap.dedent(
			'''\
			Variable     | Table                          | Label                                                    | Type 
github jtleider / censusdata / test / test_variable_info.py View on Github external
testtable = censusdata.censustable('acs5', 2015, 'B19013')
		printedtable = io.StringIO()
		sys.stdout = printedtable
		censusdata.printtable(testtable)
		sys.stdout = sys.__stdout__
		self.assertEqual(printedtable.getvalue(), textwrap.dedent(
			'''\
			Variable     | Table                          | Label                                                    | Type 
			-------------------------------------------------------------------------------------------------------------------
			B19013_001E  | B19013. Median Household Incom | Median household income in the past 12 months (in 2015 I | int  
			-------------------------------------------------------------------------------------------------------------------
			'''))
		printedtable.close()
		printedtable = io.StringIO()
		sys.stdout = printedtable
		censusdata.printtable(testtable, moe=True)
		sys.stdout = sys.__stdout__
		self.assertEqual(printedtable.getvalue(), textwrap.dedent(
			'''\
			Variable     | Table                          | Label                                                    | Type 
			-------------------------------------------------------------------------------------------------------------------
			B19013_001E  | B19013. Median Household Incom | Median household income in the past 12 months (in 2015 I | int  
			B19013_001M  | B19013. Median Household Incom | !! Margin of Error for Median household income in the pa | int  
			-------------------------------------------------------------------------------------------------------------------
			'''))
		printedtable.close()

CensusData

Download data from U.S. Census API

MIT
Latest version published 3 years ago

Package Health Score

42 / 100
Full package analysis