In [1]:
from synthpop.recipes.starter import Starter
from synthpop.synthesizer import synthesize_all, enable_logging 
import os
import pandas as pd

In [2]:
starter = Starter(os.environ["CENSUS"], "CA", "Santa Clara County")

In [ ]:
ind = pd.Series(["06", "085", "508203", "3"], index=["state", "county", "tract", "block group"])

In [12]:
%time households, persons, fit = synthesize_all(starter, indexes=[ind])


Synthesizing at geog level: 'block_group' (number of geographies is 1075)
Synthesizing geog id:
state              06
county            085
tract          508203
block group         3
dtype: object
Drawing 884 households
CPU times: user 1.79 s, sys: 28.5 ms, total: 1.82 s
Wall time: 1.83 s

In [7]:
households.head(3)


Out[7]:
serialno RT DIVISION PUMA00 PUMA10 REGION ST ADJHSG ADJINC WGTP ... WGTP76 WGTP77 WGTP78 WGTP79 WGTP80 cars workers children income cat_id
0 2012000030460 H 9 -9 08502 4 06 1000000 1010207 18 ... 5 27 21 16 6 two or more one yes gt100 45
1 2012000776236 H 9 -9 08502 4 06 1000000 1010207 17 ... 33 15 34 30 16 one one yes gt35-lt100 28
2 2012001433300 H 9 -9 08502 4 06 1000000 1010207 22 ... 6 21 24 10 35 one one yes gt100 27

3 rows × 208 columns


In [8]:
persons.head(3)


Out[8]:
serialno RT SPORDER PUMA00 PUMA10 ST ADJINC PWGTP AGEP CIT ... PWGTP76 PWGTP77 PWGTP78 PWGTP79 PWGTP80 age race sex cat_id hh_id
0 2012000030460 P 1 -9 08502 06 1010207 18 46 4 ... 5 28 21 16 6 35 to 60 asian female 16 0
1 2012000030460 P 1 -9 08502 06 1010207 18 46 4 ... 5 28 21 16 6 35 to 60 asian female 16 6
2 2012000030460 P 1 -9 08502 06 1010207 18 46 4 ... 5 28 21 16 6 35 to 60 asian female 16 20

3 rows × 295 columns


In [9]:
fit


Out[9]:
{BlockGroupID(state='06', county='085', tract='508203', block_group='3'): FitQuality(household_chisq=1033957.2104660122, household_p=0.0, people_chisq=86.359051234185131, people_p=4.0257811248627773e-07)}

In [13]:
starter = Starter(os.environ["CENSUS"], "MD", "Montgomery County")

In [15]:
ind = pd.Series(["24", "031", "700101", "1"], index=["state", "county", "tract", "block group"])

In [17]:
%time households, persons, fit = synthesize_all(starter, indexes=[ind])


Synthesizing at geog level: 'block_group' (number of geographies is 614)
Synthesizing geog id:
state              24
county            031
tract          700101
block group         1
dtype: object
Drawing 548 households
CPU times: user 873 ms, sys: 39.7 ms, total: 913 ms
Wall time: 929 ms

In [ ]: