Ejemplo n.º 1
0
    def test_multi_index(self):

        import rowgenerators as rg

        df = rg.dataframe('census://RI/140/B17001').mi()

        print(df.head())

        df = rg.dataframe('census://RI/140/B11001A').mi()

        print(df.head())
Ejemplo n.º 2
0
    def test_basic_fetch(self):
        import rowgenerators as rg

        year = 2018
        release = 5
        state = 'CA'
        sl = 'tract'
        b11016 = rg.dataframe(f'census://{year}/{release}/{state}/{sl}/B11016')

        print(b11016.head())
Ejemplo n.º 3
0
    def test_dimensions(self):

        import rowgenerators as rg

        df = rg.dataframe('census://CA/140/B17001')

        print(type(df))

        #for c in df.table.columns:
        #    print(c.unique_id, c.sex, c.race, c.age, c.poverty_status)

        print(df.head())
Ejemplo n.º 4
0
    def test_split_tables(self):

        # Table b24121 Detailed Occupation by Median Earnings for the Full-time, Year-round Civilian Population is split
        # across multiple segments.
        from publicdata.census.files.generators import Table, TableMeta, SequenceFile
        from publicdata.census.files.metafiles import TableLookup
        from itertools import islice

        sequence_file = SequenceFile(2017, 5, 'RI', 50, 85)
        print(sequence_file.header_url)
        print(len(list(sequence_file.columns)))

        for c in list(sequence_file.columns)[:10]:
            print(c.row)

        sequence_file = SequenceFile(2017, 5, 'RI', 50, 86)
        print(len(list(sequence_file.columns)))

        sequence_file = SequenceFile(2017, 5, 'RI', 50, 87)
        print(len(list(sequence_file.columns)))
        print(sequence_file.est_url)

        print('\n'.join(str(e) for e in list(islice(sequence_file, 10))))

        meta = TableMeta(2017, 5)

        print(len(meta.tables['b24121'].columns))

        tl = TableLookup(2017, 5)
        print (tl.url)

        table = Table(2017, 5, 'RI', 40, 'B24121')

        self.assertEqual(1056, (len(list(table.file_headers))))
        self.assertEqual(1056, len(list(table.columns)))

        from rowgenerators import dataframe
        df = dataframe('census://2016/5/RI/40/B24121')
Ejemplo n.º 5
0
def census_table(table, state, sl='state', year=2018, release=5):
    import rowgenerators as rg
    return rg.dataframe(f'census://{year}/{release}/{state}/{sl}/{table}')
Ejemplo n.º 6
0
    def test_B02001(self):
        import rowgenerators as rg

        raceeth = rg.dataframe('census://2017/5/CA/tract/B02001')