Skip to content

Commit

Permalink
convert jtfc alt to int, auto downcast to efficient int type
Browse files Browse the repository at this point in the history
  • Loading branch information
i-am-sijia committed May 7, 2024
1 parent 0198e2d commit 1613034
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions activitysim/abm/models/joint_tour_frequency_composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,11 @@ def joint_tour_frequency_composition(

# we expect there to be an alt with no tours - which we can use to backfill non-travelers
no_tours_alt = 0
households_merged["joint_tour_frequency_composition"] = (
choices.reindex(households_merged.index).fillna(no_tours_alt).astype(str)
# keep memory usage down by downcasting
households_merged["joint_tour_frequency_composition"] = pd.to_numeric(
choices.reindex(households_merged.index).fillna(no_tours_alt),
downcast="integer",
)
households_merged["joint_tour_frequency_composition"] = households_merged[
"joint_tour_frequency_composition"
].astype("category")

households_merged["num_hh_joint_tours"] = (
joint_tours.groupby("household_id")
Expand Down

0 comments on commit 1613034

Please sign in to comment.