Config Updates Required for ActivitySim 1.3.5 #946
Replies: 3 comments
-
Here is some more information regarding the stricter enforcement of categories point above. We were trying to recode trip mode in our airport ground access model - https://github.com/SANDAG/ABM/blob/ABM3_develop/src/asim/configs/common_airport/write_trip_matrices_annotate_trips_preprocessor.csv#L34. However, that results in an error because we need to add new categories to the trip_mode column before the update occurs. We would be interested in hearing about a better way to overcome this hurdle. Thanks! |
Beta Was this translation helpful? Give feedback.
-
I think we need to update the logic in the assign_in_place function. I believe moving the handling of categoricals to before df.update(df2) is called and updating the logic a bit around this change should solve the error. Tagging @i-am-sijia to see if she ran into this elsewhere during the categorical data development work and has a different solution in mind. |
Beta Was this translation helpful? Give feedback.
-
The crash in the airport model happens when the preprocessor tries to update an existing categorical column in Say If we update/overwrite
Thoughts on solutionWhen I implemented categoricals for ActivitySim with pandas 1.x, I encountered a similar but slightly different issue with pd.concat() - in appending two categoricals with different category values (e.g., the The solution I implemented at the time was to first take the union of the two categoricals before appending. See [1][2]. I believe a similar approach can be applied to the current issue. I've implemented a solution in PR #948. @JoeJimFlood will you please check if that resolves the crash in your airport model? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
To get a head start on identifying what changes we would need to make to our configuration files for ActivitySim v1.3.5, we conducted a full run of ABM3 with the current state of the repo. There were a couple of model crashes that were likely consequences of the upgrade to Pandas 2.x. While these aren't issues that we need (or have the time to wait for) to be fixed, I did want to let the community know about them in case other ActivitySim users who want to use v1.3.5 need to make the same changes to their configuration files or extensions.
Deprecation of DataFrame.append()
One of the changes that Pandas made for version 2 was that the
append
method for theDataFrame
object was deprecated. This method was called in ourairport_returns
extension that is used in our airport access models. The workaround for this is fairly straightforward, asdf.append(df2)
can be replaced bydf = pd.concat([df, df2])
. This change can be seen in this commit.Stricter enforcement of categories when updating a categorical field
The trip modes that are chosen in our airport access models are actually the arrival modes that people use to access the airport. For example, different parking or ridehail locations are recorded as different modes and there are additional options not present in other models (such as hotel courtesy shuttles). Because these are different from the modes that we use for assignment, the write trip matrices preprocessor copies the
trip_mode
column to a column calledarrival_mode
. The values are then recoded to match the trip modes that are used in assignment. This involves adding categories to thetrip_mode
field, which worked with Pandas 1.x but not Pandas 2.x. To get around this, we created a new column calledtrip_mode_assign
and had the trip tables used for assignment be defined based on those values. However, our internal reporting relies on thetrip_mode
column of the airport model output files having the correct categories, so a post-processing step was added to delete thetrip_mode
field (that information is already stored inarrival_mode
and rename thetrip_mode_assign
field totrip_mode
. These changes can be seen in this commit.Beta Was this translation helpful? Give feedback.
All reactions