File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -225,11 +225,11 @@ def check_hh_per_zone(cls, land_use: pd.DataFrame):
225225 def check_pop_per_zone (cls , land_use : pd .DataFrame ):
226226 persons = TABLE_STORE ["persons" ]
227227 households = TABLE_STORE ["households" ]
228- pop = persons .groupby (
229- persons . household_id . map (
230- lambda hhid : households . set_index ( "household_id" ). home_zone_id [ hhid ]
231- )
232- ). person_id . nunique ()
228+ persons_per_household = persons .groupby ("household_id" ). size ()
229+ hh = households [[ "household_id" , "home_zone_id" ]]. merge ( persons_per_household . rename ( "persons_per_household" ), on = "household_id" )
230+ pop = (
231+ hh . groupby ( households . home_zone_id )[ "persons_per_household" ]. sum ( )
232+ )
233233 return (pop == land_use .set_index ("zone_id" ).TOTPOP ).reindex (land_use .index )
234234
235235
You can’t perform that action at this time.
0 commit comments