Skip to content

Commit 5ea0548

Browse files
Make sure the county IDs are assigned
1 parent 94fea44 commit 5ea0548

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

demos/models/marriage.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,14 @@ def update_married_households_random(
196196

197197
# If geoid_col is set, we copy the geoid from old households to new ones
198198
if module_config.geoid_col is not None:
199-
new_hh_county = households.local.loc[
199+
new_hh_geoid = households.local.loc[
200200
all_df.loc[first_index & neither_head_index, "household_id"],
201201
module_config.geoid_col,
202202
].values
203-
households.local.loc[new_hh_ids, module_config.geoid_col] = new_hh_county
204-
203+
households.local.loc[new_hh_ids, module_config.geoid_col] = new_hh_geoid
204+
county_assignment = households.local.loc[all_df.loc[first_index & neither_head_index, "household_id"],
205+
"lcm_county_id"].values
206+
households.local.loc[new_hh_ids, "lcm_county_id"] = county_assignment
205207
## Decide who is household head in the households where the head left
206208
head_left_index = (all_df.relate == 0) & (all_df.household_id != all_df.new_hh_id)
207209
head_left_households = all_df[head_left_index]["household_id"].unique()
@@ -274,12 +276,14 @@ def update_divorce(persons, households, divorce_list, get_new_households):
274276

275277
# If geoid_col is set, we copy the geoid from old households to new ones
276278
if module_config.geoid_col is not None:
277-
county_assignment = households.local.loc[
279+
geoid_assignment = households.local.loc[
278280
old_household_id, module_config.geoid_col
279281
].values
280282
households.local.loc[new_households, module_config.geoid_col] = (
281-
county_assignment
283+
geoid_assignment
282284
)
285+
county_assignment = households.local.loc[old_household_id, "lcm_county_id"].values
286+
households.local.loc[new_households, "lcm_county_id"] = county_assignment
283287

284288
## Updates for people staying
285289
persons.local.loc[person_staying_index, "relate"] = 0

0 commit comments

Comments
 (0)