Skip to content

Commit

Permalink
input tables have capitalized fields
Browse files Browse the repository at this point in the history
  • Loading branch information
bstabler committed Aug 25, 2021
1 parent e0c77f4 commit 39d7407
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Description,Target,Expression
#,, annotate households table after import
,_PERSON_COUNT,"lambda query, persons, households: persons.query(query).groupby('household_id').size().reindex(households.index).fillna(0).astype(np.int8)"
#,,FIXME households.income can be negative - so we clip?
income,income,households.hincp.fillna(0)
income,income,households.HINCP.fillna(0)
income_in_thousands,income_in_thousands,(income / 1000).clip(lower=0)
income_segment,income_segment,"pd.cut(income_in_thousands, bins=[-np.inf, 30, 60, 100, np.inf], labels=[1, 2, 3, 4]).astype(int)"
#,,
Expand All @@ -27,8 +27,8 @@ num_children_6_to_12,num_children_6_to_12,"_PERSON_COUNT('6 <= age <= 12', perso
num_children_16_to_17,num_children_16_to_17,"_PERSON_COUNT('16 <= age <= 17', persons, households)"
num_college_age,num_college_age,"_PERSON_COUNT('18 <= age <= 24', persons, households)"
num_young_adults,num_young_adults,"_PERSON_COUNT('25 <= age <= 34', persons, households)"
non_family,non_family,households.hht.isin(HHT_NONFAMILY)
family,family,households.hht.isin(HHT_FAMILY)
non_family,non_family,households.HHT.isin(HHT_NONFAMILY)
family,family,households.HHT.isin(HHT_FAMILY)
home_is_urban,home_is_urban,"reindex(land_use.AreaType, households.home_zone_id) < setting('urban_threshold')"
home_is_rural,home_is_rural,"reindex(land_use.AreaType, households.home_zone_id) > setting('rural_threshold')"
home_in_detroit,home_in_detroit,"reindex(land_use.COUNTY, households.home_zone_id) == 1"
Expand Down
16 changes: 8 additions & 8 deletions activitysim/examples/example_semcog/configs/annotate_persons.csv
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ age_16_p,age_16_p,persons.age >= 16
adult,adult,persons.age >= 18
male,male,persons.sex == 1
female,female,persons.sex == 2
,esr,persons.esr.fillna(0)
,wkhp,persons.wkhp.fillna(0)
,wkw,persons.wkw.fillna(0)
,schg,persons.schg.fillna(0)
,mil,persons.mil.fillna(0)
,esr,persons.ESR.fillna(0)
,wkhp,persons.WKHP.fillna(0)
,wkw,persons.WKW.fillna(0)
,schg,persons.SCHG.fillna(0)
,mil,persons.MIL.fillna(0)
employment status type,pemploy,np.zeros(len(persons))
,pemploy,"np.where(persons.age < 16, PEMPLOY_CHILD, PEMPLOY_PART)"
,pemploy,"np.where((persons['age'] >= 16) & ((esr == 3) | (esr == 6)), PEMPLOY_NOT, pemploy)"
Expand Down Expand Up @@ -60,10 +60,10 @@ is_worker,is_worker,"np.where((pemploy == PEMPLOY_FULL) |( pemploy == PEMPLOY_PA
home_zone_id,home_zone_id,"reindex(households.home_zone_id, persons.household_id)"
hh_child,hh_child,"reindex(households.children, persons.household_id)"
person number,PNUM,persons.member_id
income,income,"reindex(households.hincp, persons.household_id)"
income,income,"reindex(households.HINCP, persons.household_id)"
income_in_thousands,income_in_thousands,(income / 1000).clip(lower=0)
income_segment,income_segment,"pd.cut(income_in_thousands, bins=[-np.inf, 30, 60, 100, np.inf], labels=[1, 2, 3, 4]).astype(int)"
is_fulltime_worker,is_fulltime_worker,"((age_16_p) & (wkhp >=35) & (wkw>=1) & (wkw<=4) & (~esr.isin([3,6])))"
is_parttime_worker,is_parttime_worker,"((age_16_p) & (~esr.isin([3,6])) & (is_fulltime_worker == False))"
recoding existing as legacy,naicsp_recode,"persons['naicsp'].replace('-9', '0000')"
coding industry according to pums,industry_naics,naicsp_recode.str[0].astype(int)*10
#recoding existing as legacy,naicsp_recode,"persons['naicsp'].replace('-9', '0000')"
#coding industry according to pums,industry_naics,naicsp_recode.str[0].astype(int)*10
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Description,Target,Expression
#,, adults get full hh_value_of_time and children get 60%
,_hh_vot,"reindex(households.hh_value_of_time, persons.household_id)"
,value_of_time,"_hh_vot.where(persons.age>=18, _hh_vot * 0.667)"
,_hh_income,"reindex(households.hincp, persons.household_id)"
,_hh_income,"reindex(households.income, persons.household_id)"
,_num_adults,"reindex(households.num_adults, persons.household_id)"
,_num_predrive_child,"reindex(households.num_predrive_child, persons.household_id)"
,_num_nonworker_adults,"reindex(households.num_nonworker_adults, persons.household_id)"
Expand Down

0 comments on commit 39d7407

Please sign in to comment.