Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions activitysim/abm/models/school_escorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ def determine_escorting_participants(
)

chaperones["chaperone_num"] = (
chaperones.sort_values("chaperone_weight", ascending=False)
chaperones.sort_values("chaperone_weight", ascending=False, kind="stable")
.groupby("household_id")
.cumcount()
+ 1
)
escortees["escortee_num"] = (
escortees.sort_values("age", ascending=True).groupby("household_id").cumcount()
escortees.sort_values("age", ascending=True, kind="stable")
.groupby("household_id")
.cumcount()
+ 1
)

Expand Down Expand Up @@ -247,7 +249,7 @@ def create_school_escorting_bundles_table(choosers, tours, stage):
)

# each chauffeur option has ride share or pure escort
bundles["chauf_num"] = np.ceil(bundles["chauf_type_num"].div(2)).astype(int)
bundles["chauf_num"] = np.ceil(bundles["chauf_type_num"].div(2)).astype("int64")

# getting bundle chauffeur id based on the chauffeur num
bundles["chauf_id"] = -1
Expand All @@ -257,7 +259,7 @@ def create_school_escorting_bundles_table(choosers, tours, stage):
choosers["chauf_id" + str(i)],
bundles["chauf_id"],
)
bundles["chauf_id"] = bundles["chauf_id"].astype(int)
bundles["chauf_id"] = bundles["chauf_id"].astype("int64")
assert (
bundles["chauf_id"] > 0
).all(), "Invalid chauf_id's for school escort bundles!"
Expand Down Expand Up @@ -586,6 +588,7 @@ def school_escorting(
by=["household_id", "school_escort_direction"],
ascending=[True, False],
inplace=True,
kind="stable",
)

school_escort_tours = school_escort_tours_trips.create_pure_school_escort_tours(
Expand Down
10 changes: 6 additions & 4 deletions activitysim/abm/models/util/school_escort_tours_trips.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def join_attributes(df, column_names):
series = (
df[col]
.fillna(-1)
.astype(int)
.astype("int64")
.astype(str)
.replace("-1", "", regex=False)
)
Expand Down Expand Up @@ -331,7 +331,7 @@ def create_chauf_trip_table(bundles):

def create_chauf_escort_trips(bundles):
chauf_trip_bundles = create_chauf_trip_table(bundles.copy())
chauf_trip_bundles["tour_id"] = bundles["chauf_tour_id"].astype(int)
chauf_trip_bundles["tour_id"] = bundles["chauf_tour_id"].astype("int64")

# departure time is the first school start in the outbound school_escort_direction and the last school end in the inbound school_escort_direction
starts = (
Expand Down Expand Up @@ -651,7 +651,7 @@ def process_tours_after_escorting_model(state: workflow.State, escort_bundles, t
num_escortees = (
escort_bundles.drop_duplicates("chauf_tour_id")
.set_index("chauf_tour_id")["num_escortees"]
.astype(int)
.astype("int64")
)
tours.loc[num_escortees.index, "num_escortees"] = num_escortees

Expand Down Expand Up @@ -921,7 +921,9 @@ def create_pure_school_escort_tours(state: workflow.State, bundles):
pe_tours["school_escort_direction"] == "inbound", "pure_escort", pd.NA
)

pe_tours = pe_tours.sort_values(by=["household_id", "person_id", "start"])
pe_tours = pe_tours.sort_values(
by=["household_id", "person_id", "start"], kind="stable"
)

# finding what the next start time for that person for scheduling
pe_tours["next_pure_escort_start"] = (
Expand Down
Loading