diff --git a/sb125_analyses/corridor_study/_utils.py b/sb125_analyses/corridor_study/_utils.py
index 5d84d4ba4..d93da68a2 100644
--- a/sb125_analyses/corridor_study/_utils.py
+++ b/sb125_analyses/corridor_study/_utils.py
@@ -80,6 +80,28 @@ def get_unique_agencies(agency_list):
return df
+def get_agencies_occurances(df):
+
+ ##get list of columns that have agency names
+ columns_to_keep = list(df.columns.values)
+
+ ## remove columns that are not agency names
+ unwanted_cols = {'transit_agency', 'unique_agencies', 'primary_mode', 'transit_submode', 'n', 'agency_count', 'n_modes_taken' }
+ columns_to_keep = [e for e in columns_to_keep if e not in unwanted_cols]
+
+ df_agencies = df.loc[:, columns_to_keep]
+
+ ## transpose the df again
+ df_agencies = pd.DataFrame(df_agencies).transpose().reset_index().rename(columns={'index':'agency'})
+
+ ##sum up the number of trips by agency
+ df_agencies['n_trips'] = df_agencies[list(df_agencies.columns)].sum(axis=1)
+
+ ## filter df to only have two cols
+ df_agencies = df_agencies>>select(_.agency, _.n_trips)
+
+ return df_agencies
+
"""
Streetlight Analysis Utils
"""
diff --git a/sb125_analyses/corridor_study/data_downloads_skirball.ipynb b/sb125_analyses/corridor_study/data_downloads_skirball.ipynb
index 91b7ce9b1..eff178baf 100644
--- a/sb125_analyses/corridor_study/data_downloads_skirball.ipynb
+++ b/sb125_analyses/corridor_study/data_downloads_skirball.ipynb
@@ -19,7 +19,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "/tmp/ipykernel_515/2202862553.py:12: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython 7.14, please import from IPython display\n",
+ "/tmp/ipykernel_469/2202862553.py:12: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython 7.14, please import from IPython display\n",
" from IPython.core.display import display\n"
]
}
@@ -108,7 +108,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "/tmp/ipykernel_515/2643890524.py:1: DtypeWarning: Columns (18,19,20,25,26,28,29,30,31,33,36,38,39,40,41,42,43) have mixed types. Specify dtype option on import or set low_memory=False.\n",
+ "/tmp/ipykernel_469/2643890524.py:1: DtypeWarning: Columns (18,19,20,25,26,28,29,30,31,33,36,38,39,40,41,42,43) have mixed types. Specify dtype option on import or set low_memory=False.\n",
" r_trips = to_snakecase(pd.read_csv(f\"{GCS_PATH}{replica_trips}\"))\n"
]
}
@@ -223,23 +223,23 @@
" \n",
"
\n",
" \n",
- " 423350 | \n",
- " 5926084662673022461 | \n",
- " 1 (Tract 2643.05, Los Angeles, CA) | \n",
- " 2643.05 (Los Angeles, CA) | \n",
+ " 314707 | \n",
+ " 8505387565750628825 | \n",
+ " 1 (Tract 1349.07, Los Angeles, CA) | \n",
+ " 1349.07 (Los Angeles, CA) | \n",
" Los Angeles County, CA | \n",
" California | \n",
- " 3 (Tract 9105.01, Los Angeles, CA) | \n",
- " 9105.01 (Los Angeles, CA) | \n",
+ " 4 (Tract 6037.02, Los Angeles, CA) | \n",
+ " 6037.02 (Los Angeles, CA) | \n",
" Los Angeles County, CA | \n",
" California | \n",
" private_auto | \n",
- " work | \n",
+ " social | \n",
" home | \n",
- " 14:57:00 | \n",
- " 16:25:56 | \n",
- " 88 | \n",
- " 57.2 | \n",
+ " 13:31:00 | \n",
+ " 14:24:59 | \n",
+ " 53 | \n",
+ " 31.2 | \n",
" unknown_vehicle_type | \n",
" other_non_bev | \n",
" NaN | \n",
@@ -247,253 +247,253 @@
" NaN | \n",
" mixed_use | \n",
" multi_family | \n",
- " civic_institutional | \n",
- " civic_institutional | \n",
- " 9280162199592818201 | \n",
- " 3819422246701548245 | \n",
- " 59.0 | \n",
+ " single_family | \n",
+ " single_family | \n",
+ " 13590816709645713585 | \n",
+ " 15626229210687624776 | \n",
+ " 63.0 | \n",
" male | \n",
" white_not_hispanic_or_latino | \n",
" employed | \n",
" in_person | \n",
- " 297058.0 | \n",
+ " 7224.0 | \n",
" private_auto | \n",
" 2.0 | \n",
- " 380443.0 | \n",
+ " 23805.0 | \n",
" two | \n",
" core | \n",
- " naics62 | \n",
+ " naics713940 | \n",
" multiple_units | \n",
" not_attending_school | \n",
- " bachelors_degree | \n",
- " owner | \n",
- " english | \n",
- " 1 (Tract 2643.05, Los Angeles, CA) | \n",
- " 2643.05 (Los Angeles, CA) | \n",
+ " some_college | \n",
+ " renter | \n",
+ " indo_european | \n",
+ " 1 (Tract 1349.07, Los Angeles, CA) | \n",
+ " 1349.07 (Los Angeles, CA) | \n",
" Los Angeles County, CA | \n",
" California | \n",
- " 3 (Tract 9105.01, Los Angeles, CA) | \n",
- " 9105.01 (Los Angeles, CA) | \n",
+ " 3 (Tract 7004, Los Angeles, CA) | \n",
+ " 7004 (Los Angeles, CA) | \n",
" Los Angeles County, CA | \n",
" California | \n",
"
\n",
" \n",
- " 245631 | \n",
- " 12533923940243185590 | \n",
- " 2 (Tract 6203.03, Los Angeles, CA) | \n",
- " 6203.03 (Los Angeles, CA) | \n",
+ " 101372 | \n",
+ " 12431969978777812348 | \n",
+ " 1 (Tract 1174.08, Los Angeles, CA) | \n",
+ " 1174.08 (Los Angeles, CA) | \n",
" Los Angeles County, CA | \n",
" California | \n",
- " 1 (Tract 29.14, Santa Barbara, CA) | \n",
- " 29.14 (Santa Barbara, CA) | \n",
- " Santa Barbara County, CA | \n",
+ " 3 (Tract 2735.02, Los Angeles, CA) | \n",
+ " 2735.02 (Los Angeles, CA) | \n",
+ " Los Angeles County, CA | \n",
" California | \n",
" private_auto | \n",
- " home | \n",
" shop | \n",
- " 17:30:40 | \n",
- " 19:53:16 | \n",
- " 142 | \n",
- " 110.3 | \n",
+ " home | \n",
+ " 17:16:00 | \n",
+ " 18:01:55 | \n",
+ " 45 | \n",
+ " 20.4 | \n",
" unknown_vehicle_type | \n",
" other_non_bev | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
+ " single_family | \n",
+ " single_family | \n",
" retail | \n",
" retail | \n",
- " multi_family | \n",
- " multi_family | \n",
- " 15212051208025649622 | \n",
- " 13620258903763937995 | \n",
- " 69.0 | \n",
- " male | \n",
- " white_not_hispanic_or_latino | \n",
+ " 3550536633128717092 | \n",
+ " 6516243422276820403 | \n",
+ " 62.0 | \n",
+ " female | \n",
+ " asian_not_hispanic_or_latino | \n",
" employed | \n",
" in_person | \n",
- " 46394.0 | \n",
+ " 27836.0 | \n",
" private_auto | \n",
- " 1.0 | \n",
- " 46394.0 | \n",
- " one | \n",
+ " 4.0 | \n",
+ " 110187.0 | \n",
+ " two | \n",
" core | \n",
- " naics515210 | \n",
- " multiple_units | \n",
- " not_attending_school | \n",
+ " naics621111 | \n",
+ " single_family | \n",
+ " graduate | \n",
" bachelors_degree | \n",
- " renter | \n",
- " english | \n",
- " 1 (Tract 29.14, Santa Barbara, CA) | \n",
- " 29.14 (Santa Barbara, CA) | \n",
- " Santa Barbara County, CA | \n",
+ " owner | \n",
+ " other | \n",
+ " 1 (Tract 1174.08, Los Angeles, CA) | \n",
+ " 1174.08 (Los Angeles, CA) | \n",
+ " Los Angeles County, CA | \n",
" California | \n",
- " 1 (Tract 6204, Los Angeles, CA) | \n",
- " 6204 (Los Angeles, CA) | \n",
+ " 3 (Tract 5435.03, Los Angeles, CA) | \n",
+ " 5435.03 (Los Angeles, CA) | \n",
" Los Angeles County, CA | \n",
" California | \n",
"
\n",
" \n",
- " 258108 | \n",
- " 15822036852902980413 | \n",
- " 1 (Tract 2643.06, Los Angeles, CA) | \n",
- " 2643.06 (Los Angeles, CA) | \n",
+ " 237178 | \n",
+ " 1520438980495662157 | \n",
+ " 4 (Tract 1175.30, Los Angeles, CA) | \n",
+ " 1175.30 (Los Angeles, CA) | \n",
" Los Angeles County, CA | \n",
" California | \n",
- " 1 (Tract 1043.21, Los Angeles, CA) | \n",
- " 1043.21 (Los Angeles, CA) | \n",
+ " 1 (Tract 9800.28, Los Angeles, CA) | \n",
+ " 9800.28 (Los Angeles, CA) | \n",
" Los Angeles County, CA | \n",
" California | \n",
" private_auto | \n",
- " home | \n",
" work | \n",
- " 14:52:00 | \n",
- " 15:40:55 | \n",
- " 48 | \n",
- " 19.9 | \n",
+ " home | \n",
+ " 07:19:00 | \n",
+ " 08:13:36 | \n",
+ " 54 | \n",
+ " 23.1 | \n",
" unknown_vehicle_type | \n",
" other_non_bev | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
- " retail | \n",
- " retail | \n",
" multi_family | \n",
" multi_family | \n",
- " 18024054114643477512 | \n",
- " 4390175249257531498 | \n",
- " 32.0 | \n",
+ " industrial | \n",
+ " industrial | \n",
+ " 8591229506040203519 | \n",
+ " 16428891936194534442 | \n",
+ " 24.0 | \n",
" male | \n",
" hispanic_or_latino_origin | \n",
" employed | \n",
" in_person | \n",
- " 12507.0 | \n",
+ " 40595.0 | \n",
" private_auto | \n",
- " 2.0 | \n",
- " 56284.0 | \n",
- " two | \n",
+ " 4.0 | \n",
+ " 102068.0 | \n",
+ " three_plus | \n",
" core | \n",
- " naics23 | \n",
+ " naics44_45 | \n",
" multiple_units | \n",
" not_attending_school | \n",
- " k_12 | \n",
+ " some_college | \n",
" renter | \n",
" spanish | \n",
- " 1 (Tract 1043.21, Los Angeles, CA) | \n",
- " 1043.21 (Los Angeles, CA) | \n",
+ " 4 (Tract 1175.30, Los Angeles, CA) | \n",
+ " 1175.30 (Los Angeles, CA) | \n",
" Los Angeles County, CA | \n",
" California | \n",
- " 1 (Tract 2643.06, Los Angeles, CA) | \n",
- " 2643.06 (Los Angeles, CA) | \n",
+ " 1 (Tract 9800.28, Los Angeles, CA) | \n",
+ " 9800.28 (Los Angeles, CA) | \n",
" Los Angeles County, CA | \n",
" California | \n",
"
\n",
" \n",
- " 146285 | \n",
- " 14712612269617851560 | \n",
- " 1 (Tract 1112.01, Los Angeles, CA) | \n",
- " 1112.01 (Los Angeles, CA) | \n",
+ " 31761 | \n",
+ " 11036673894851484580 | \n",
+ " 1 (Tract 6506.06, Los Angeles, CA) | \n",
+ " 6506.06 (Los Angeles, CA) | \n",
" Los Angeles County, CA | \n",
" California | \n",
- " 1 (Tract 2653.01, Los Angeles, CA) | \n",
- " 2653.01 (Los Angeles, CA) | \n",
- " Los Angeles County, CA | \n",
+ " 2 (Tract 56, Kern, CA) | \n",
+ " 56 (Kern, CA) | \n",
+ " Kern County, CA | \n",
" California | \n",
" private_auto | \n",
- " school | \n",
- " eat | \n",
- " 07:59:00 | \n",
- " 08:49:01 | \n",
- " 50 | \n",
- " 17.9 | \n",
+ " work | \n",
+ " social | \n",
+ " 07:00:00 | \n",
+ " 09:53:47 | \n",
+ " 173 | \n",
+ " 142.9 | \n",
" unknown_vehicle_type | \n",
" other_non_bev | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
+ " multi_family | \n",
+ " multi_family | \n",
" retail | \n",
" retail | \n",
- " education | \n",
- " education | \n",
- " 6730005140840342218 | \n",
- " 8465342313702012328 | \n",
- " 20.0 | \n",
- " male | \n",
- " hispanic_or_latino_origin | \n",
- " not_in_labor_force | \n",
- " unemployed_under_16_not_in_labor_force | \n",
- " 0.0 | \n",
- " other_travel_mode | \n",
- " 3.0 | \n",
- " 5211.0 | \n",
- " two | \n",
+ " 673878670446905249 | \n",
+ " 1964084087473365831 | \n",
+ " 42.0 | \n",
+ " female | \n",
+ " asian_not_hispanic_or_latino | \n",
+ " employed | \n",
+ " in_person | \n",
+ " 23942.0 | \n",
+ " private_auto | \n",
+ " 2.0 | \n",
+ " 80947.0 | \n",
+ " one | \n",
" core | \n",
- " not_working | \n",
+ " naics23 | \n",
" multiple_units | \n",
- " undergraduate | \n",
- " some_college | \n",
+ " not_attending_school | \n",
+ " bachelors_degree | \n",
" renter | \n",
- " spanish | \n",
- " 1 (Tract 2653.04, Los Angeles, CA) | \n",
- " 2653.04 (Los Angeles, CA) | \n",
+ " asian_pacific | \n",
+ " 1 (Tract 6506.06, Los Angeles, CA) | \n",
+ " 6506.06 (Los Angeles, CA) | \n",
" Los Angeles County, CA | \n",
" California | \n",
- " 1 (Tract 2653.01, Los Angeles, CA) | \n",
- " 2653.01 (Los Angeles, CA) | \n",
- " Los Angeles County, CA | \n",
+ " 2 (Tract 56, Kern, CA) | \n",
+ " 56 (Kern, CA) | \n",
+ " Kern County, CA | \n",
" California | \n",
"
\n",
" \n",
- " 58235 | \n",
- " 16619945285298383268 | \n",
- " 1 (Tract 5436.07, Los Angeles, CA) | \n",
- " 5436.07 (Los Angeles, CA) | \n",
+ " 193932 | \n",
+ " 7236618342537072261 | \n",
+ " 1 (Tract 2733, Los Angeles, CA) | \n",
+ " 2733 (Los Angeles, CA) | \n",
" Los Angeles County, CA | \n",
" California | \n",
- " 1 (Tract 1321.02, Los Angeles, CA) | \n",
- " 1321.02 (Los Angeles, CA) | \n",
+ " 1 (Tract 9800.08, Los Angeles, CA) | \n",
+ " 9800.08 (Los Angeles, CA) | \n",
" Los Angeles County, CA | \n",
" California | \n",
- " private_auto | \n",
+ " auto_passenger | \n",
" work | \n",
- " home | \n",
- " 12:39:00 | \n",
- " 13:28:17 | \n",
- " 49 | \n",
- " 34.9 | \n",
+ " eat | \n",
+ " 09:19:07 | \n",
+ " 09:46:59 | \n",
+ " 27 | \n",
+ " 20.0 | \n",
" unknown_vehicle_type | \n",
- " other_non_bev | \n",
+ " unknown_fuel_type | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
- " single_family | \n",
- " single_family | \n",
" retail | \n",
" retail | \n",
- " 14684325219070757087 | \n",
- " 7566196984556086662 | \n",
- " 64.0 | \n",
- " male | \n",
+ " mixed_use | \n",
+ " office | \n",
+ " 2321481644760744007 | \n",
+ " 11390460785703966067 | \n",
+ " 24.0 | \n",
+ " female | \n",
" asian_not_hispanic_or_latino | \n",
" employed | \n",
" in_person | \n",
- " 83858.0 | \n",
- " private_auto | \n",
- " 1.0 | \n",
- " 83858.0 | \n",
- " one | \n",
+ " 27831.0 | \n",
+ " public_transit | \n",
+ " 9.0 | \n",
+ " 256361.0 | \n",
+ " three_plus | \n",
" core | \n",
- " naics44_45 | \n",
- " several_units | \n",
+ " naics621493 | \n",
+ " single_family | \n",
" not_attending_school | \n",
- " some_college | \n",
+ " bachelors_degree | \n",
" owner | \n",
" asian_pacific | \n",
- " 1 (Tract 5436.07, Los Angeles, CA) | \n",
- " 5436.07 (Los Angeles, CA) | \n",
+ " 2 (Tract 1958.03, Los Angeles, CA) | \n",
+ " 1958.03 (Los Angeles, CA) | \n",
" Los Angeles County, CA | \n",
" California | \n",
- " 1 (Tract 1321.02, Los Angeles, CA) | \n",
- " 1321.02 (Los Angeles, CA) | \n",
+ " 1 (Tract 9800.08, Los Angeles, CA) | \n",
+ " 9800.08 (Los Angeles, CA) | \n",
" Los Angeles County, CA | \n",
" California | \n",
"
\n",
@@ -503,151 +503,151 @@
],
"text/plain": [
" activity_id origin_bgrp_2020 \\\n",
- "423350 5926084662673022461 1 (Tract 2643.05, Los Angeles, CA) \n",
- "245631 12533923940243185590 2 (Tract 6203.03, Los Angeles, CA) \n",
- "258108 15822036852902980413 1 (Tract 2643.06, Los Angeles, CA) \n",
- "146285 14712612269617851560 1 (Tract 1112.01, Los Angeles, CA) \n",
- "58235 16619945285298383268 1 (Tract 5436.07, Los Angeles, CA) \n",
+ "314707 8505387565750628825 1 (Tract 1349.07, Los Angeles, CA) \n",
+ "101372 12431969978777812348 1 (Tract 1174.08, Los Angeles, CA) \n",
+ "237178 1520438980495662157 4 (Tract 1175.30, Los Angeles, CA) \n",
+ "31761 11036673894851484580 1 (Tract 6506.06, Los Angeles, CA) \n",
+ "193932 7236618342537072261 1 (Tract 2733, Los Angeles, CA) \n",
"\n",
" origin_trct_2020 origin_cty_2020 origin_st_2020 \\\n",
- "423350 2643.05 (Los Angeles, CA) Los Angeles County, CA California \n",
- "245631 6203.03 (Los Angeles, CA) Los Angeles County, CA California \n",
- "258108 2643.06 (Los Angeles, CA) Los Angeles County, CA California \n",
- "146285 1112.01 (Los Angeles, CA) Los Angeles County, CA California \n",
- "58235 5436.07 (Los Angeles, CA) Los Angeles County, CA California \n",
+ "314707 1349.07 (Los Angeles, CA) Los Angeles County, CA California \n",
+ "101372 1174.08 (Los Angeles, CA) Los Angeles County, CA California \n",
+ "237178 1175.30 (Los Angeles, CA) Los Angeles County, CA California \n",
+ "31761 6506.06 (Los Angeles, CA) Los Angeles County, CA California \n",
+ "193932 2733 (Los Angeles, CA) Los Angeles County, CA California \n",
"\n",
" destination_bgrp_2020 destination_trct_2020 \\\n",
- "423350 3 (Tract 9105.01, Los Angeles, CA) 9105.01 (Los Angeles, CA) \n",
- "245631 1 (Tract 29.14, Santa Barbara, CA) 29.14 (Santa Barbara, CA) \n",
- "258108 1 (Tract 1043.21, Los Angeles, CA) 1043.21 (Los Angeles, CA) \n",
- "146285 1 (Tract 2653.01, Los Angeles, CA) 2653.01 (Los Angeles, CA) \n",
- "58235 1 (Tract 1321.02, Los Angeles, CA) 1321.02 (Los Angeles, CA) \n",
- "\n",
- " destination_cty_2020 destination_st_2020 primary_mode \\\n",
- "423350 Los Angeles County, CA California private_auto \n",
- "245631 Santa Barbara County, CA California private_auto \n",
- "258108 Los Angeles County, CA California private_auto \n",
- "146285 Los Angeles County, CA California private_auto \n",
- "58235 Los Angeles County, CA California private_auto \n",
+ "314707 4 (Tract 6037.02, Los Angeles, CA) 6037.02 (Los Angeles, CA) \n",
+ "101372 3 (Tract 2735.02, Los Angeles, CA) 2735.02 (Los Angeles, CA) \n",
+ "237178 1 (Tract 9800.28, Los Angeles, CA) 9800.28 (Los Angeles, CA) \n",
+ "31761 2 (Tract 56, Kern, CA) 56 (Kern, CA) \n",
+ "193932 1 (Tract 9800.08, Los Angeles, CA) 9800.08 (Los Angeles, CA) \n",
+ "\n",
+ " destination_cty_2020 destination_st_2020 primary_mode \\\n",
+ "314707 Los Angeles County, CA California private_auto \n",
+ "101372 Los Angeles County, CA California private_auto \n",
+ "237178 Los Angeles County, CA California private_auto \n",
+ "31761 Kern County, CA California private_auto \n",
+ "193932 Los Angeles County, CA California auto_passenger \n",
"\n",
" trip_purpose previous_trip_purpose trip_start_time trip_end_time \\\n",
- "423350 work home 14:57:00 16:25:56 \n",
- "245631 home shop 17:30:40 19:53:16 \n",
- "258108 home work 14:52:00 15:40:55 \n",
- "146285 school eat 07:59:00 08:49:01 \n",
- "58235 work home 12:39:00 13:28:17 \n",
+ "314707 social home 13:31:00 14:24:59 \n",
+ "101372 shop home 17:16:00 18:01:55 \n",
+ "237178 work home 07:19:00 08:13:36 \n",
+ "31761 work social 07:00:00 09:53:47 \n",
+ "193932 work eat 09:19:07 09:46:59 \n",
"\n",
" trip_duration_minutes trip_distance_miles vehicle_type \\\n",
- "423350 88 57.2 unknown_vehicle_type \n",
- "245631 142 110.3 unknown_vehicle_type \n",
- "258108 48 19.9 unknown_vehicle_type \n",
- "146285 50 17.9 unknown_vehicle_type \n",
- "58235 49 34.9 unknown_vehicle_type \n",
- "\n",
- " vehicle_fuel_type transit_submode transit_agency transit_route \\\n",
- "423350 other_non_bev NaN NaN NaN \n",
- "245631 other_non_bev NaN NaN NaN \n",
- "258108 other_non_bev NaN NaN NaN \n",
- "146285 other_non_bev NaN NaN NaN \n",
- "58235 other_non_bev NaN NaN NaN \n",
+ "314707 53 31.2 unknown_vehicle_type \n",
+ "101372 45 20.4 unknown_vehicle_type \n",
+ "237178 54 23.1 unknown_vehicle_type \n",
+ "31761 173 142.9 unknown_vehicle_type \n",
+ "193932 27 20.0 unknown_vehicle_type \n",
+ "\n",
+ " vehicle_fuel_type transit_submode transit_agency transit_route \\\n",
+ "314707 other_non_bev NaN NaN NaN \n",
+ "101372 other_non_bev NaN NaN NaN \n",
+ "237178 other_non_bev NaN NaN NaN \n",
+ "31761 other_non_bev NaN NaN NaN \n",
+ "193932 unknown_fuel_type NaN NaN NaN \n",
"\n",
" origin_land_use origin_building_use destination_land_use \\\n",
- "423350 mixed_use multi_family civic_institutional \n",
- "245631 retail retail multi_family \n",
- "258108 retail retail multi_family \n",
- "146285 retail retail education \n",
- "58235 single_family single_family retail \n",
+ "314707 mixed_use multi_family single_family \n",
+ "101372 single_family single_family retail \n",
+ "237178 multi_family multi_family industrial \n",
+ "31761 multi_family multi_family retail \n",
+ "193932 retail retail mixed_use \n",
"\n",
" destination_building_use trip_taker_person_id trip_taker_household_id \\\n",
- "423350 civic_institutional 9280162199592818201 3819422246701548245 \n",
- "245631 multi_family 15212051208025649622 13620258903763937995 \n",
- "258108 multi_family 18024054114643477512 4390175249257531498 \n",
- "146285 education 6730005140840342218 8465342313702012328 \n",
- "58235 retail 14684325219070757087 7566196984556086662 \n",
+ "314707 single_family 13590816709645713585 15626229210687624776 \n",
+ "101372 retail 3550536633128717092 6516243422276820403 \n",
+ "237178 industrial 8591229506040203519 16428891936194534442 \n",
+ "31761 retail 673878670446905249 1964084087473365831 \n",
+ "193932 office 2321481644760744007 11390460785703966067 \n",
"\n",
" trip_taker_age trip_taker_sex trip_taker_race_ethnicity \\\n",
- "423350 59.0 male white_not_hispanic_or_latino \n",
- "245631 69.0 male white_not_hispanic_or_latino \n",
- "258108 32.0 male hispanic_or_latino_origin \n",
- "146285 20.0 male hispanic_or_latino_origin \n",
- "58235 64.0 male asian_not_hispanic_or_latino \n",
- "\n",
- " trip_taker_employment_status trip_taker_wfh \\\n",
- "423350 employed in_person \n",
- "245631 employed in_person \n",
- "258108 employed in_person \n",
- "146285 not_in_labor_force unemployed_under_16_not_in_labor_force \n",
- "58235 employed in_person \n",
+ "314707 63.0 male white_not_hispanic_or_latino \n",
+ "101372 62.0 female asian_not_hispanic_or_latino \n",
+ "237178 24.0 male hispanic_or_latino_origin \n",
+ "31761 42.0 female asian_not_hispanic_or_latino \n",
+ "193932 24.0 female asian_not_hispanic_or_latino \n",
+ "\n",
+ " trip_taker_employment_status trip_taker_wfh \\\n",
+ "314707 employed in_person \n",
+ "101372 employed in_person \n",
+ "237178 employed in_person \n",
+ "31761 employed in_person \n",
+ "193932 employed in_person \n",
"\n",
" trip_taker_individual_income trip_taker_commute_mode \\\n",
- "423350 297058.0 private_auto \n",
- "245631 46394.0 private_auto \n",
- "258108 12507.0 private_auto \n",
- "146285 0.0 other_travel_mode \n",
- "58235 83858.0 private_auto \n",
+ "314707 7224.0 private_auto \n",
+ "101372 27836.0 private_auto \n",
+ "237178 40595.0 private_auto \n",
+ "31761 23942.0 private_auto \n",
+ "193932 27831.0 public_transit \n",
"\n",
" trip_taker_household_size trip_taker_household_income \\\n",
- "423350 2.0 380443.0 \n",
- "245631 1.0 46394.0 \n",
- "258108 2.0 56284.0 \n",
- "146285 3.0 5211.0 \n",
- "58235 1.0 83858.0 \n",
+ "314707 2.0 23805.0 \n",
+ "101372 4.0 110187.0 \n",
+ "237178 4.0 102068.0 \n",
+ "31761 2.0 80947.0 \n",
+ "193932 9.0 256361.0 \n",
"\n",
" trip_taker_available_vehicles trip_taker_resident_type \\\n",
- "423350 two core \n",
- "245631 one core \n",
- "258108 two core \n",
- "146285 two core \n",
- "58235 one core \n",
+ "314707 two core \n",
+ "101372 two core \n",
+ "237178 three_plus core \n",
+ "31761 one core \n",
+ "193932 three_plus core \n",
"\n",
" trip_taker_industry trip_taker_building_type \\\n",
- "423350 naics62 multiple_units \n",
- "245631 naics515210 multiple_units \n",
- "258108 naics23 multiple_units \n",
- "146285 not_working multiple_units \n",
- "58235 naics44_45 several_units \n",
+ "314707 naics713940 multiple_units \n",
+ "101372 naics621111 single_family \n",
+ "237178 naics44_45 multiple_units \n",
+ "31761 naics23 multiple_units \n",
+ "193932 naics621493 single_family \n",
"\n",
" trip_taker_school_grade_attending trip_taker_education \\\n",
- "423350 not_attending_school bachelors_degree \n",
- "245631 not_attending_school bachelors_degree \n",
- "258108 not_attending_school k_12 \n",
- "146285 undergraduate some_college \n",
- "58235 not_attending_school some_college \n",
+ "314707 not_attending_school some_college \n",
+ "101372 graduate bachelors_degree \n",
+ "237178 not_attending_school some_college \n",
+ "31761 not_attending_school bachelors_degree \n",
+ "193932 not_attending_school bachelors_degree \n",
"\n",
" trip_taker_tenure trip_taker_language \\\n",
- "423350 owner english \n",
- "245631 renter english \n",
- "258108 renter spanish \n",
- "146285 renter spanish \n",
- "58235 owner asian_pacific \n",
+ "314707 renter indo_european \n",
+ "101372 owner other \n",
+ "237178 renter spanish \n",
+ "31761 renter asian_pacific \n",
+ "193932 owner asian_pacific \n",
"\n",
" trip_taker_home_bgrp_2020 trip_taker_home_trct_2020 \\\n",
- "423350 1 (Tract 2643.05, Los Angeles, CA) 2643.05 (Los Angeles, CA) \n",
- "245631 1 (Tract 29.14, Santa Barbara, CA) 29.14 (Santa Barbara, CA) \n",
- "258108 1 (Tract 1043.21, Los Angeles, CA) 1043.21 (Los Angeles, CA) \n",
- "146285 1 (Tract 2653.04, Los Angeles, CA) 2653.04 (Los Angeles, CA) \n",
- "58235 1 (Tract 5436.07, Los Angeles, CA) 5436.07 (Los Angeles, CA) \n",
- "\n",
- " trip_taker_home_cty_2020 trip_taker_home_st_2020 \\\n",
- "423350 Los Angeles County, CA California \n",
- "245631 Santa Barbara County, CA California \n",
- "258108 Los Angeles County, CA California \n",
- "146285 Los Angeles County, CA California \n",
- "58235 Los Angeles County, CA California \n",
+ "314707 1 (Tract 1349.07, Los Angeles, CA) 1349.07 (Los Angeles, CA) \n",
+ "101372 1 (Tract 1174.08, Los Angeles, CA) 1174.08 (Los Angeles, CA) \n",
+ "237178 4 (Tract 1175.30, Los Angeles, CA) 1175.30 (Los Angeles, CA) \n",
+ "31761 1 (Tract 6506.06, Los Angeles, CA) 6506.06 (Los Angeles, CA) \n",
+ "193932 2 (Tract 1958.03, Los Angeles, CA) 1958.03 (Los Angeles, CA) \n",
+ "\n",
+ " trip_taker_home_cty_2020 trip_taker_home_st_2020 \\\n",
+ "314707 Los Angeles County, CA California \n",
+ "101372 Los Angeles County, CA California \n",
+ "237178 Los Angeles County, CA California \n",
+ "31761 Los Angeles County, CA California \n",
+ "193932 Los Angeles County, CA California \n",
"\n",
" trip_taker_work_bgrp_2020 trip_taker_work_trct_2020 \\\n",
- "423350 3 (Tract 9105.01, Los Angeles, CA) 9105.01 (Los Angeles, CA) \n",
- "245631 1 (Tract 6204, Los Angeles, CA) 6204 (Los Angeles, CA) \n",
- "258108 1 (Tract 2643.06, Los Angeles, CA) 2643.06 (Los Angeles, CA) \n",
- "146285 1 (Tract 2653.01, Los Angeles, CA) 2653.01 (Los Angeles, CA) \n",
- "58235 1 (Tract 1321.02, Los Angeles, CA) 1321.02 (Los Angeles, CA) \n",
+ "314707 3 (Tract 7004, Los Angeles, CA) 7004 (Los Angeles, CA) \n",
+ "101372 3 (Tract 5435.03, Los Angeles, CA) 5435.03 (Los Angeles, CA) \n",
+ "237178 1 (Tract 9800.28, Los Angeles, CA) 9800.28 (Los Angeles, CA) \n",
+ "31761 2 (Tract 56, Kern, CA) 56 (Kern, CA) \n",
+ "193932 1 (Tract 9800.08, Los Angeles, CA) 9800.08 (Los Angeles, CA) \n",
"\n",
" trip_taker_work_cty_2020 trip_taker_work_st_2020 \n",
- "423350 Los Angeles County, CA California \n",
- "245631 Los Angeles County, CA California \n",
- "258108 Los Angeles County, CA California \n",
- "146285 Los Angeles County, CA California \n",
- "58235 Los Angeles County, CA California "
+ "314707 Los Angeles County, CA California \n",
+ "101372 Los Angeles County, CA California \n",
+ "237178 Los Angeles County, CA California \n",
+ "31761 Kern County, CA California \n",
+ "193932 Los Angeles County, CA California "
]
},
"execution_count": 8,
@@ -788,23 +788,23 @@
"text/html": [
"\n",
"\n",
- "\n",
+ "\n",
""
],
"text/plain": [
"alt.Chart(...)"
]
},
- "execution_count": 55,
+ "execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
@@ -3046,7 +2833,7 @@
},
{
"cell_type": "code",
- "execution_count": 56,
+ "execution_count": 54,
"id": "60df338f-801f-49a1-a26f-0be5e03bddf3",
"metadata": {},
"outputs": [
@@ -3120,7 +2907,7 @@
"1 Metro - Los Angeles"
]
},
- "execution_count": 56,
+ "execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
@@ -3149,102 +2936,179 @@
},
{
"cell_type": "code",
- "execution_count": 57,
- "id": "8af03d60-4537-44d3-b82f-d857625e47c3",
- "metadata": {},
- "outputs": [],
- "source": [
- "columns_to_keep = [\"AVTA\",\n",
- " \"Beach Cities Transit-City of Redondo Beach\",\n",
- " \"LADOT126\",\n",
- " \"Metro - Los Angeles\",\n",
- " \"LA Go Bus\",\n",
- " \"LADOTDT\",\n",
- " \"Amtrak\",\n",
- " \"Big Blue Bus\",\n",
- " \"GTrans\",\n",
- " \"LADOTMVN\",\n",
- " \"Long Beach Transit\",\n",
- " \"Santa Clarita Transit\",\n",
- " \"Foothill Transit\",\n",
- " \"Culver CityBus\",\n",
- " \"Metrolink Trains\",\n",
- " \"LADOTMVS\"\n",
- " ]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 58,
- "id": "6951b590-cef8-44bd-b27d-0b18893609c5",
- "metadata": {},
- "outputs": [],
- "source": [
- "# agency_indv_count.sample()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 59,
- "id": "cca56d58-5e3f-430c-adde-15ca665d46f8",
- "metadata": {},
- "outputs": [],
- "source": [
- "df_agencies = agency_indv_count.loc[:, columns_to_keep]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 60,
- "id": "814dde3a-d303-4044-9df1-464e408bf460",
- "metadata": {},
- "outputs": [],
- "source": [
- "df_agencies = pd.DataFrame(df_agencies).transpose().reset_index().rename(columns={'index':'agency'})"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 61,
- "id": "84174911-2243-430c-ab73-1fecb2552094",
+ "execution_count": null,
+ "id": "febd910a-2f1d-4b99-bb3b-76adb11f0b63",
"metadata": {},
"outputs": [],
- "source": [
- "# df_agencies"
- ]
+ "source": []
},
{
"cell_type": "code",
- "execution_count": 62,
- "id": "202923d2-b869-4a72-8a02-ce229a65d815",
+ "execution_count": 55,
+ "id": "96b794f2-bcfd-4afb-9ce5-8793c15fe199",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
- "/tmp/ipykernel_515/2517619377.py:1: FutureWarning: Dropping of nuisance columns in DataFrame reductions (with 'numeric_only=None') is deprecated; in a future version this will raise TypeError. Select only valid columns before calling the reduction.\n",
+ "/home/jovyan/data-analyses/sb125_analyses/corridor_study/_utils.py:98: FutureWarning: Dropping of nuisance columns in DataFrame reductions (with 'numeric_only=None') is deprecated; in a future version this will raise TypeError. Select only valid columns before calling the reduction.\n",
" df_agencies['n_trips'] = df_agencies[list(df_agencies.columns)].sum(axis=1)\n"
]
}
],
"source": [
- "df_agencies['n_trips'] = df_agencies[list(df_agencies.columns)].sum(axis=1)"
+ "df_agencies = _utils.get_agencies_occurances(df)"
]
},
{
"cell_type": "code",
- "execution_count": 63,
- "id": "2b31eb23-e1e6-43c6-8b0e-ccb3802cd09d",
+ "execution_count": 56,
+ "id": "80cbffde-6686-4921-b543-84e52f97a0c5",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " agency | \n",
+ " n_trips | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " Culver CityBus | \n",
+ " 28 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " Foothill Transit | \n",
+ " 1 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " LA Go Bus | \n",
+ " 1 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " Metro - Los Angeles | \n",
+ " 195 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " Amtrak | \n",
+ " 8 | \n",
+ "
\n",
+ " \n",
+ " 5 | \n",
+ " AVTA | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 6 | \n",
+ " GTrans | \n",
+ " 1 | \n",
+ "
\n",
+ " \n",
+ " 7 | \n",
+ " Metrolink Trains | \n",
+ " 1 | \n",
+ "
\n",
+ " \n",
+ " 8 | \n",
+ " LADOTMVN | \n",
+ " 54 | \n",
+ "
\n",
+ " \n",
+ " 9 | \n",
+ " Long Beach Transit | \n",
+ " 1 | \n",
+ "
\n",
+ " \n",
+ " 10 | \n",
+ " Santa Clarita Transit | \n",
+ " 28 | \n",
+ "
\n",
+ " \n",
+ " 11 | \n",
+ " LADOTDT | \n",
+ " 3 | \n",
+ "
\n",
+ " \n",
+ " 12 | \n",
+ " Big Blue Bus | \n",
+ " 37 | \n",
+ "
\n",
+ " \n",
+ " 13 | \n",
+ " LADOT126 | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 14 | \n",
+ " LADOTMVS | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 15 | \n",
+ " Beach Cities Transit-City of Redondo Beach | \n",
+ " 2 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " agency n_trips\n",
+ "0 Culver CityBus 28\n",
+ "1 Foothill Transit 1\n",
+ "2 LA Go Bus 1\n",
+ "3 Metro - Los Angeles 195\n",
+ "4 Amtrak 8\n",
+ "5 AVTA 4\n",
+ "6 GTrans 1\n",
+ "7 Metrolink Trains 1\n",
+ "8 LADOTMVN 54\n",
+ "9 Long Beach Transit 1\n",
+ "10 Santa Clarita Transit 28\n",
+ "11 LADOTDT 3\n",
+ "12 Big Blue Bus 37\n",
+ "13 LADOT126 4\n",
+ "14 LADOTMVS 4\n",
+ "15 Beach Cities Transit-City of Redondo Beach 2"
+ ]
+ },
+ "execution_count": 56,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
- "df_agencies = df_agencies>>select(_.agency, _.n_trips)"
+ "df_agencies"
]
},
{
"cell_type": "code",
- "execution_count": 64,
+ "execution_count": 57,
"id": "f98c76b9-b83f-42c3-aa12-702ade72ac38",
"metadata": {},
"outputs": [],
@@ -3254,17 +3118,7 @@
},
{
"cell_type": "code",
- "execution_count": 65,
- "id": "f1267faf-e28c-4208-ae79-43b31f67f705",
- "metadata": {},
- "outputs": [],
- "source": [
- "# df_agencies"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 66,
+ "execution_count": 59,
"id": "bf160b81-1bc2-4374-9529-6400252d5e4f",
"metadata": {},
"outputs": [
@@ -3273,23 +3127,23 @@
"text/html": [
"\n",
"\n",
- "\n",
+ "\n",
""
],
"text/plain": [
"alt.Chart(...)"
]
},
- "execution_count": 66,
+ "execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
@@ -3372,7 +3226,7 @@
},
{
"cell_type": "code",
- "execution_count": 67,
+ "execution_count": 60,
"id": "16b45917-adc3-44d0-8d76-15ccd4083d26",
"metadata": {},
"outputs": [
@@ -3395,7 +3249,7 @@
},
{
"cell_type": "code",
- "execution_count": 68,
+ "execution_count": 61,
"id": "5163926e-82bd-4c25-9486-45229d09a0d1",
"metadata": {},
"outputs": [],
@@ -3408,7 +3262,7 @@
},
{
"cell_type": "code",
- "execution_count": 69,
+ "execution_count": 62,
"id": "636e7771-0ba7-42e9-af1d-e3e998ff8599",
"metadata": {},
"outputs": [
@@ -3531,7 +3385,7 @@
"11 public_transit visitor 56"
]
},
- "execution_count": 69,
+ "execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
@@ -3542,7 +3396,7 @@
},
{
"cell_type": "code",
- "execution_count": 70,
+ "execution_count": 63,
"id": "90c5d683-91c5-4663-accd-4e45027a3e49",
"metadata": {},
"outputs": [
@@ -3551,23 +3405,23 @@
"text/html": [
"\n",
"\n",
- "\n",
+ "\n",
"