Skip to content

Commit b019c4b

Browse files
committed
make fast_eval more robust
1 parent 804e780 commit b019c4b

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

activitysim/core/fast_eval.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ def _get_cleaned_column_resolvers(
3131
# give the raw arrays to the compute engine. This is potentially a breaking
3232
# change if any of the operations in the eval string require a pd.Series.
3333
if raw:
34+
# Performance tradeoff: in the dict below, we iterate over `df.items`,
35+
# which yields tuples of (column_name, data as pd.Series). This is marginally
36+
# slower than iterating over `df.columns` and `df._iter_column_arrays()`,
37+
# but the latter is not in Pandas' public API, and may be removed in the future.
3438
return {
35-
clean_column_name(k): v
36-
for k, v in zip(df.columns, df._iter_column_arrays())
37-
if not isinstance(k, int)
39+
clean_column_name(k): v for k, v in df.items() if not isinstance(k, int)
3840
}
3941

4042
# CHANGED FROM PANDAS: do not call df.dtype inside the dict comprehension loop

0 commit comments

Comments
 (0)