Skip to content

Commit f5c7d9e

Browse files
committed
improve speed on later components
1 parent 14f8dd1 commit f5c7d9e

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Description,Target,Expression
22
non-motorized and walk tran and tnc set to null,selected_vehicle,np.nan
3-
tours using sov option,selected_vehicle,"np.where(df.tour_mode.isin(['DRIVEALONEFREE','DRIVEALONEPAY','DRIVE_LOC','DRIVE_LRF','DRIVE_EXP','DRIVE_HVY','DRIVE_COM']), df.vehicle_occup_1, selected_vehicle).astype(df.vehicle_occup_1.dtype)"
4-
tours using sr2 option,selected_vehicle,"np.where(df.tour_mode.isin(['SHARED2FREE','SHARED2PAY']), df.vehicle_occup_2, selected_vehicle).astype(df.vehicle_occup_1.dtype)"
5-
tours using sr3 option,selected_vehicle,"np.where(df.tour_mode.isin(['SHARED3FREE','SHARED3PAY']), df['vehicle_occup_3.5'], selected_vehicle).astype(df.vehicle_occup_1.dtype)"
3+
tours using sov option,selected_vehicle,"pd.Series(np.where(df.tour_mode.isin(['DRIVEALONEFREE','DRIVEALONEPAY','DRIVE_LOC','DRIVE_LRF','DRIVE_EXP','DRIVE_HVY','DRIVE_COM']), df.vehicle_occup_1, selected_vehicle), index=df.index, dtype=df.vehicle_occup_1.dtype)"
4+
tours using sr2 option,selected_vehicle,"pd.Series(np.where(df.tour_mode.isin(['SHARED2FREE','SHARED2PAY']), df.vehicle_occup_2, selected_vehicle), index=df.index, dtype=df.vehicle_occup_1.dtype)"
5+
tours using sr3 option,selected_vehicle,"pd.Series(np.where(df.tour_mode.isin(['SHARED3FREE','SHARED3PAY']), df['vehicle_occup_3.5'], selected_vehicle), index=df.index, dtype=df.vehicle_occup_1.dtype)"
66
parent tour vehicle,_parent_selected_vehicle,"reindex(df.selected_vehicle, df.parent_tour_id) if 'selected_vehicle' in df.columns else np.nan"
7-
assign parent tour vehicle to atwork subtours,selected_vehicle,"np.where(df.tour_category == 'atwork', _parent_selected_vehicle, selected_vehicle)"
7+
assign parent tour vehicle to atwork subtours,selected_vehicle,"pd.Series(np.where(df.tour_category == 'atwork', _parent_selected_vehicle, selected_vehicle), index=df.index, dtype=df.vehicle_occup_1.dtype)"
88
is non-driving tour,_is_non_driving_tour,"df.tour_mode.isin(['WALK','BIKE','WALK_LOC','WALK_LRF','WALK_EXP','WALK_HVY','WALK_COM','TAXI','TNC_SINGLE','TNC_SHARED'])"
9-
atwork subtours whose parent tour did not use a vehicle use non_hh_veh,selected_vehicle,"np.where(~_is_non_driving_tour & (df.tour_category == 'atwork') & pd.isna(selected_vehicle),'non_hh_veh', selected_vehicle)"
9+
atwork subtours whose parent tour did not use a vehicle use non_hh_veh,selected_vehicle,"pd.Series(np.where(~_is_non_driving_tour & (df.tour_category == 'atwork') & pd.isna(selected_vehicle),'non_hh_veh', selected_vehicle), index=df.index, dtype=df.vehicle_occup_1.dtype)"

ext-configs/tour_mode_choice_annotate_choosers_preprocessor.csv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ local,_DF_IS_TOUR,'tour_type' in df.columns
1717
,is_escort,(df.tour_type == 'escort') if _DF_IS_TOUR else False
1818
#Auto operating costs,,
1919
,parent_tour_veh,"reindex(tours['selected_vehicle'], df['parent_tour_id']) if 'selected_vehicle' in df.columns else np.nan"
20-
,sov_veh_option,"np.where(is_atwork_subtour, parent_tour_veh, df.get('vehicle_occup_1', np.nan))"
21-
,sr2_veh_option,"np.where(is_atwork_subtour, parent_tour_veh, df.get('vehicle_occup_2', np.nan))"
22-
,sr3p_veh_option,"np.where(is_atwork_subtour, parent_tour_veh, df.get('vehicle_occup_3.5', np.nan))"
20+
,sov_veh_option,"pd.Series(np.where(is_atwork_subtour, parent_tour_veh, df.get('vehicle_occup_1', np.nan)), index=df.index, dtype=df.vehicle_occup_1.dtype if 'vehicle_occup_1' in df.columns else np.float64)"
21+
,sr2_veh_option,"pd.Series(np.where(is_atwork_subtour, parent_tour_veh, df.get('vehicle_occup_2', np.nan)), index=df.index, dtype=df.vehicle_occup_2.dtype if 'vehicle_occup_2' in df.columns else np.float64)"
22+
,sr3p_veh_option,"pd.Series(np.where(is_atwork_subtour, parent_tour_veh, df.get('vehicle_occup_3.5', np.nan)), index=df.index, dtype=df['vehicle_occup_3.5'].dtype if 'vehicle_occup_3.5' in df.columns else np.float64)"
2323
,sov_auto_op_cost,"reindex(vehicles.groupby('vehicle_type')['auto_operating_cost'].mean(), pd.Series(sov_veh_option, df.index)) if 'vehicle_occup_1' in df.columns else np.nan"
2424
,sov_auto_op_cost,"np.where(sov_auto_op_cost.isna() | (pd.Series(sov_veh_option, df.index) == 'non_hh_veh'), costPerMile, sov_auto_op_cost)"
2525
,sr2_auto_op_cost,"reindex(vehicles.groupby('vehicle_type')['auto_operating_cost'].mean(), pd.Series(sr2_veh_option, df.index)) if 'vehicle_occup_2' in df.columns else np.nan"

ext-configs/trip_mode_choice_annotate_trips_preprocessor.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Description,Target,Expression
1919
,tour_mode_is_drive_transit,i_tour_mode.isin(I_DRIVE_TRANSIT_MODES)
2020
,tour_mode_is_ride_hail,i_tour_mode.isin(I_RIDE_HAIL_MODES)
2121
#,,
22-
,selected_tour_vehicle,"reindex(tours.selected_vehicle, df.tour_id)"
22+
,selected_tour_vehicle,"pd.Series(reindex(tours.selected_vehicle, df.tour_id), index=df.index, dtype=tours.selected_vehicle.dtype)"
2323
,auto_op_cost,"reindex(vehicles.groupby('vehicle_type')['auto_operating_cost'].mean(), pd.Series(selected_tour_vehicle, df.index))"
2424
,auto_op_cost,"np.where(pd.isna(auto_op_cost), costPerMile, auto_op_cost)"
2525
,inbound,~df.outbound

0 commit comments

Comments
 (0)