diff --git a/sb125_analyses/corridor_study/_utils.py b/sb125_analyses/corridor_study/_utils.py index d93da68a2..aba4dcdc6 100644 --- a/sb125_analyses/corridor_study/_utils.py +++ b/sb125_analyses/corridor_study/_utils.py @@ -35,6 +35,10 @@ def get_tranist_agency_counts(df, primary_mode_col, transit_mode_col, transit_ag modes = (df >>filter(_[primary_mode_col] =="public_transit") >>count(_[transit_mode_col])>>arrange(-_.n)) + + modes[transit_mode_col] = modes[transit_mode_col].astype(str) + # modes[transit_agency_col] = modes[transit_agency_col].astype(str) + modes['n_modes_taken'] = modes[transit_mode_col].apply(lambda x: len(x.split())) return agencies, modes diff --git a/sb125_analyses/corridor_study/data_downloads_baybridge.ipynb b/sb125_analyses/corridor_study/data_downloads_baybridge.ipynb index 9db75d062..181e33062 100644 --- a/sb125_analyses/corridor_study/data_downloads_baybridge.ipynb +++ b/sb125_analyses/corridor_study/data_downloads_baybridge.ipynb @@ -19,7 +19,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "/tmp/ipykernel_734/4150955979.py:10: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython 7.14, please import from IPython display\n", + "/tmp/ipykernel_483/4150955979.py:10: 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" ] } @@ -116,7 +116,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "/tmp/ipykernel_734/2643890524.py:1: DtypeWarning: Columns (2,4,5,9,10,11,18,25,26,29,30,35,36,40,43,48,50) have mixed types. Specify dtype option on import or set low_memory=False.\n", + "/tmp/ipykernel_483/2643890524.py:1: DtypeWarning: Columns (2,4,5,9,10,11,18,25,26,29,30,35,36,40,43,48,50) 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" ] } @@ -231,69 +231,69 @@ " \n", " \n", " \n", - " 553553\n", - " single_family\n", - " 54\n", - " indo_european\n", - " 3551.25 (Contra Costa, CA)\n", - " 3983964165863772194\n", + " 199078\n", + " multi_family\n", + " 46\n", + " other\n", + " 4501.01 (Alameda, CA)\n", + " 69970950706205725\n", " male\n", - " 1 (Tract 3551.25, Contra Costa, CA)\n", + " 2 (Tract 4501.01, Alameda, CA)\n", " California\n", " California\n", - " asian_not_hispanic_or_latino\n", + " white_not_hispanic_or_latino\n", " NaN\n", " NaN\n", " core\n", " unknown_vehicle_type\n", - " 35.0\n", - " 9101372044721674445\n", - " 1 (Tract 117, San Francisco, CA)\n", - " office\n", + " 39.0\n", + " 4486197526664593040\n", + " 2 (Tract 105, San Francisco, CA)\n", + " non_retail_attraction\n", " in_person\n", " California\n", " San Francisco\n", - " 1 (Tract 117, San Francisco, CA)\n", - " 117 (San Francisco, CA)\n", - " 385384.0\n", - " 1 (Tract 3551.25, Contra Costa, CA)\n", + " 2 (Tract 105, San Francisco, CA)\n", + " 105 (San Francisco, CA)\n", + " 237966.0\n", + " 2 (Tract 4501.01, Alameda, CA)\n", " public_transit\n", - " three_plus\n", + " one\n", " auto_passenger\n", " home\n", - " single_family\n", + " multiple_units\n", " NaN\n", " California\n", " 4.0\n", - " Contra Costa\n", - " office\n", - " naics54\n", - " owner\n", + " Alameda\n", + " non_retail_attraction\n", + " naics31_33\n", + " renter\n", " unknown_fuel_type\n", - " 3551.25 (Contra Costa, CA)\n", - " 117 (San Francisco, CA)\n", + " 4501.01 (Alameda, CA)\n", + " 105 (San Francisco, CA)\n", " advanced_degree\n", - " 07:05:00\n", - " 171281.0\n", + " 04:53:00\n", + " 237966.0\n", " employed\n", " work\n", - " single_family\n", + " multi_family\n", " San Francisco\n", - " 39.7\n", + " 36.7\n", " not_attending_school\n", - " Contra Costa\n", - " 10449641475948959375\n", - " 07:59:40\n", + " Alameda\n", + " 11699013211020046684\n", + " 05:39:20\n", " \n", " \n", - " 279158\n", - " single_family\n", - " 22\n", + " 362910\n", + " multi_family\n", + " 65\n", " english\n", - " 4230 (Alameda, CA)\n", - " 1400348454720165044\n", - " male\n", - " 2 (Tract 4230, Alameda, CA)\n", + " 615.06 (San Francisco, CA)\n", + " 14710396768871133663\n", + " female\n", + " 1 (Tract 615.06, San Francisco, CA)\n", " California\n", " California\n", " white_not_hispanic_or_latino\n", @@ -301,209 +301,209 @@ " NaN\n", " core\n", " unknown_vehicle_type\n", - " 51.0\n", - " 3185555683721970505\n", - " 3 (Tract 117, San Francisco, CA)\n", - " non_retail_attraction\n", - " unemployed_under_16_not_in_labor_force\n", + " 30.0\n", + " 3388798362605091248\n", + " 1 (Tract 3551.13, Contra Costa, CA)\n", + " single_family\n", + " in_person\n", " California\n", - " San Francisco\n", - " Does not have work/school location\n", - " 117 (San Francisco, CA)\n", - " 47611.0\n", - " 2 (Tract 4230, Alameda, CA)\n", - " other_travel_mode\n", - " two\n", - " private_auto\n", + " Contra Costa\n", + " 1 (Tract 615.01, San Francisco, CA)\n", + " 3551.13 (Contra Costa, CA)\n", + " 237586.0\n", + " 1 (Tract 615.06, San Francisco, CA)\n", + " walking\n", + " one\n", + " auto_passenger\n", " home\n", - " single_family\n", + " multiple_units\n", " NaN\n", - " Does not have work/school location\n", + " California\n", " 2.0\n", - " Alameda\n", - " non_retail_attraction\n", - " not_working\n", - " owner\n", - " other_non_bev\n", - " 4230 (Alameda, CA)\n", - " Does not have work/school location\n", - " bachelors_degree\n", - " 13:29:00\n", - " 0.0\n", - " not_in_labor_force\n", - " recreation\n", + " San Francisco\n", " single_family\n", - " Does not have work/school location\n", - " 11.7\n", + " naics5151\n", + " renter\n", + " unknown_fuel_type\n", + " 615.06 (San Francisco, CA)\n", + " 615.01 (San Francisco, CA)\n", + " bachelors_degree\n", + " 17:25:00\n", + " 77510.0\n", + " employed\n", + " social\n", + " mixed_use\n", + " San Francisco\n", + " 33.7\n", " not_attending_school\n", - " Alameda\n", - " 17632012171564480054\n", - " 13:51:00\n", + " San Francisco\n", + " 14279596460102489210\n", + " 18:30:49\n", " \n", " \n", - " 181137\n", - " retail\n", - " 33\n", - " spanish\n", - " 111.02 (San Francisco, CA)\n", - " 10599523862883086877\n", + " 397490\n", + " education\n", + " 53\n", + " indo_european\n", + " 301.02 (San Francisco, CA)\n", + " 11603413512180790232\n", " male\n", - " 2 (Tract 4094, Alameda, CA)\n", + " 5 (Tract 4381, Alameda, CA)\n", " California\n", " California\n", - " hispanic_or_latino_origin\n", + " two_races_not_hispanic_or_latino\n", " NaN\n", " NaN\n", " core\n", " unknown_vehicle_type\n", - " 20.0\n", - " 2671538980829985577\n", - " 2 (Tract 4094, Alameda, CA)\n", - " single_family\n", + " 46.0\n", + " 17748416797468343771\n", + " 5 (Tract 4381, Alameda, CA)\n", + " multi_family\n", " in_person\n", " California\n", " Alameda\n", - " 2 (Tract 111.02, San Francisco, CA)\n", - " 4094 (Alameda, CA)\n", - " 75775.0\n", - " 2 (Tract 111.02, San Francisco, CA)\n", - " public_transit\n", - " one\n", - " auto_passenger\n", + " 3 (Tract 301.02, San Francisco, CA)\n", + " 4381 (Alameda, CA)\n", + " 101548.0\n", + " 3 (Tract 301.02, San Francisco, CA)\n", + " private_auto\n", + " two\n", + " private_auto\n", " work\n", - " single_family\n", + " several_units\n", " NaN\n", " California\n", - " 3.0\n", + " 4.0\n", " San Francisco\n", - " single_family\n", - " naics31_33\n", + " multi_family\n", + " naics61\n", " owner\n", - " unknown_fuel_type\n", - " 4094 (Alameda, CA)\n", - " 111.02 (San Francisco, CA)\n", - " high_school\n", - " 15:00:00\n", - " 25705.0\n", + " other_non_bev\n", + " 4381 (Alameda, CA)\n", + " 301.02 (San Francisco, CA)\n", + " some_college\n", + " 20:53:05\n", + " 71051.0\n", " employed\n", " home\n", - " mixed_use\n", + " education\n", " San Francisco\n", - " 18.3\n", + " 34.1\n", " not_attending_school\n", " Alameda\n", - " 13577701224844795977\n", - " 15:33:51\n", + " 9371860226741686287\n", + " 21:46:49\n", " \n", " \n", - " 287640\n", - " retail\n", - " 70\n", - " spanish\n", - " 228.01 (San Francisco, CA)\n", - " 15708312656173489894\n", + " 646286\n", + " single_family\n", + " 42\n", + " asian_pacific\n", + " 3851 (Contra Costa, CA)\n", + " 8856161571093041221\n", " female\n", - " 1 (Tract 2529.08, Solano, CA)\n", + " 2 (Tract 3851, Contra Costa, CA)\n", " California\n", " California\n", - " hispanic_or_latino_origin\n", + " asian_not_hispanic_or_latino\n", " NaN\n", " NaN\n", " core\n", " unknown_vehicle_type\n", - " 50.0\n", - " 3771951352339899063\n", - " 1 (Tract 2529.08, Solano, CA)\n", - " single_family\n", + " 61.0\n", + " 1096586971710081424\n", + " 1 (Tract 177, San Francisco, CA)\n", + " retail\n", " unemployed_under_16_not_in_labor_force\n", " California\n", - " Solano\n", + " San Francisco\n", " Does not have work/school location\n", - " 2529.08 (Solano, CA)\n", - " 184297.0\n", - " 2 (Tract 228.01, San Francisco, CA)\n", + " 177 (San Francisco, CA)\n", + " 163758.0\n", + " 2 (Tract 3851, Contra Costa, CA)\n", " other_travel_mode\n", " two\n", " auto_passenger\n", - " eat\n", + " home\n", " single_family\n", " NaN\n", " Does not have work/school location\n", - " 5.0\n", - " San Francisco\n", - " single_family\n", + " 4.0\n", + " Contra Costa\n", + " mixed_use\n", " not_working\n", " owner\n", " unknown_fuel_type\n", - " 2529.08 (Solano, CA)\n", + " 3851 (Contra Costa, CA)\n", " Does not have work/school location\n", " high_school\n", - " 22:41:00\n", - " 0.0\n", + " 17:10:00\n", + " 11123.0\n", " not_in_labor_force\n", - " home\n", - " mixed_use\n", + " eat\n", + " single_family\n", " Does not have work/school location\n", - " 57.2\n", + " 17.5\n", " not_attending_school\n", - " Solano\n", - " 10756826488872628366\n", - " 23:51:07\n", + " Contra Costa\n", + " 15224202816917079679\n", + " 17:52:23\n", " \n", " \n", - " 626533\n", - " open_space\n", - " 65\n", - " asian_pacific\n", - " 6032 (San Mateo, CA)\n", - " 9100171167746262744\n", + " 432031\n", + " single_family\n", + " 30\n", + " english\n", + " 3790 (Contra Costa, CA)\n", + " 11125850078941310816\n", " male\n", - " 2 (Tract 2521.08, Solano, CA)\n", + " 1 (Tract 3790, Contra Costa, CA)\n", " California\n", " California\n", - " asian_not_hispanic_or_latino\n", + " white_not_hispanic_or_latino\n", " NaN\n", " NaN\n", " core\n", " unknown_vehicle_type\n", - " 74.0\n", - " 6650138049950149530\n", - " 2 (Tract 2521.08, Solano, CA)\n", - " single_family\n", - " unemployed_under_16_not_in_labor_force\n", + " 58.0\n", + " 17878107943481256906\n", + " 3 (Tract 151, San Francisco, CA)\n", + " office\n", + " in_person\n", " California\n", - " Solano\n", - " Does not have work/school location\n", - " 2521.08 (Solano, CA)\n", - " 181344.0\n", - " 4 (Tract 6032, San Mateo, CA)\n", - " other_travel_mode\n", - " two\n", + " San Francisco\n", + " 3 (Tract 151, San Francisco, CA)\n", + " 151 (San Francisco, CA)\n", + " 191291.0\n", + " 1 (Tract 3790, Contra Costa, CA)\n", " private_auto\n", - " recreation\n", + " two\n", + " auto_passenger\n", + " home\n", " single_family\n", " NaN\n", - " Does not have work/school location\n", - " 2.0\n", - " San Mateo\n", - " single_family\n", - " not_working\n", - " owner\n", - " other_non_bev\n", - " 2521.08 (Solano, CA)\n", - " Does not have work/school location\n", - " advanced_degree\n", - " 20:33:00\n", - " 91849.0\n", - " not_in_labor_force\n", - " home\n", + " California\n", + " 3.0\n", + " Contra Costa\n", " mixed_use\n", - " Does not have work/school location\n", - " 53.6\n", + " naics42\n", + " owner\n", + " unknown_fuel_type\n", + " 3790 (Contra Costa, CA)\n", + " 151 (San Francisco, CA)\n", + " some_college\n", + " 13:50:00\n", + " 81981.0\n", + " employed\n", + " work\n", + " single_family\n", + " San Francisco\n", + " 18.4\n", " not_attending_school\n", - " Solano\n", - " 1309500236464925123\n", - " 21:38:12\n", + " Contra Costa\n", + " 17663033273047637228\n", + " 14:20:30\n", " \n", " \n", "\n", @@ -511,151 +511,158 @@ ], "text/plain": [ " origin_building_use trip_duration_minutes trip_taker_language \\\n", - "553553 single_family 54 indo_european \n", - "279158 single_family 22 english \n", - "181137 retail 33 spanish \n", - "287640 retail 70 spanish \n", - "626533 open_space 65 asian_pacific \n", + "199078 multi_family 46 other \n", + "362910 multi_family 65 english \n", + "397490 education 53 indo_european \n", + "646286 single_family 42 asian_pacific \n", + "432031 single_family 30 english \n", "\n", " origin_trct_2020 trip_taker_household_id trip_taker_sex \\\n", - "553553 3551.25 (Contra Costa, CA) 3983964165863772194 male \n", - "279158 4230 (Alameda, CA) 1400348454720165044 male \n", - "181137 111.02 (San Francisco, CA) 10599523862883086877 male \n", - "287640 228.01 (San Francisco, CA) 15708312656173489894 female \n", - "626533 6032 (San Mateo, CA) 9100171167746262744 male \n", + "199078 4501.01 (Alameda, CA) 69970950706205725 male \n", + "362910 615.06 (San Francisco, CA) 14710396768871133663 female \n", + "397490 301.02 (San Francisco, CA) 11603413512180790232 male \n", + "646286 3851 (Contra Costa, CA) 8856161571093041221 female \n", + "432031 3790 (Contra Costa, CA) 11125850078941310816 male \n", "\n", " trip_taker_home_bgrp_2020 origin_st_2020 \\\n", - "553553 1 (Tract 3551.25, Contra Costa, CA) California \n", - "279158 2 (Tract 4230, Alameda, CA) California \n", - "181137 2 (Tract 4094, Alameda, CA) California \n", - "287640 1 (Tract 2529.08, Solano, CA) California \n", - "626533 2 (Tract 2521.08, Solano, CA) California \n", - "\n", - " trip_taker_home_st_2020 trip_taker_race_ethnicity transit_agency \\\n", - "553553 California asian_not_hispanic_or_latino NaN \n", - "279158 California white_not_hispanic_or_latino NaN \n", - "181137 California hispanic_or_latino_origin NaN \n", - "287640 California hispanic_or_latino_origin NaN \n", - "626533 California asian_not_hispanic_or_latino NaN \n", - "\n", - " transit_route trip_taker_resident_type vehicle_type \\\n", - "553553 NaN core unknown_vehicle_type \n", - "279158 NaN core unknown_vehicle_type \n", - "181137 NaN core unknown_vehicle_type \n", - "287640 NaN core unknown_vehicle_type \n", - "626533 NaN core unknown_vehicle_type \n", - "\n", - " trip_taker_age activity_id destination_bgrp_2020 \\\n", - "553553 35.0 9101372044721674445 1 (Tract 117, San Francisco, CA) \n", - "279158 51.0 3185555683721970505 3 (Tract 117, San Francisco, CA) \n", - "181137 20.0 2671538980829985577 2 (Tract 4094, Alameda, CA) \n", - "287640 50.0 3771951352339899063 1 (Tract 2529.08, Solano, CA) \n", - "626533 74.0 6650138049950149530 2 (Tract 2521.08, Solano, CA) \n", - "\n", - " destination_building_use trip_taker_wfh \\\n", - "553553 office in_person \n", - "279158 non_retail_attraction unemployed_under_16_not_in_labor_force \n", - "181137 single_family in_person \n", - "287640 single_family unemployed_under_16_not_in_labor_force \n", - "626533 single_family unemployed_under_16_not_in_labor_force \n", - "\n", - " destination_st_2020 destination_cty_2020 \\\n", - "553553 California San Francisco \n", - "279158 California San Francisco \n", - "181137 California Alameda \n", - "287640 California Solano \n", - "626533 California Solano \n", - "\n", - " trip_taker_work_bgrp_2020 destination_trct_2020 \\\n", - "553553 1 (Tract 117, San Francisco, CA) 117 (San Francisco, CA) \n", - "279158 Does not have work/school location 117 (San Francisco, CA) \n", - "181137 2 (Tract 111.02, San Francisco, CA) 4094 (Alameda, CA) \n", - "287640 Does not have work/school location 2529.08 (Solano, CA) \n", - "626533 Does not have work/school location 2521.08 (Solano, CA) \n", - "\n", - " trip_taker_household_income origin_bgrp_2020 \\\n", - "553553 385384.0 1 (Tract 3551.25, Contra Costa, CA) \n", - "279158 47611.0 2 (Tract 4230, Alameda, CA) \n", - "181137 75775.0 2 (Tract 111.02, San Francisco, CA) \n", - "287640 184297.0 2 (Tract 228.01, San Francisco, CA) \n", - "626533 181344.0 4 (Tract 6032, San Mateo, CA) \n", - "\n", - " trip_taker_commute_mode trip_taker_available_vehicles primary_mode \\\n", - "553553 public_transit three_plus auto_passenger \n", - "279158 other_travel_mode two private_auto \n", - "181137 public_transit one auto_passenger \n", - "287640 other_travel_mode two auto_passenger \n", - "626533 other_travel_mode two private_auto \n", + "199078 2 (Tract 4501.01, Alameda, CA) California \n", + "362910 1 (Tract 615.06, San Francisco, CA) California \n", + "397490 5 (Tract 4381, Alameda, CA) California \n", + "646286 2 (Tract 3851, Contra Costa, CA) California \n", + "432031 1 (Tract 3790, Contra Costa, CA) California \n", + "\n", + " trip_taker_home_st_2020 trip_taker_race_ethnicity \\\n", + "199078 California white_not_hispanic_or_latino \n", + "362910 California white_not_hispanic_or_latino \n", + "397490 California two_races_not_hispanic_or_latino \n", + "646286 California asian_not_hispanic_or_latino \n", + "432031 California white_not_hispanic_or_latino \n", + "\n", + " transit_agency transit_route trip_taker_resident_type \\\n", + "199078 NaN NaN core \n", + "362910 NaN NaN core \n", + "397490 NaN NaN core \n", + "646286 NaN NaN core \n", + "432031 NaN NaN core \n", + "\n", + " vehicle_type trip_taker_age activity_id \\\n", + "199078 unknown_vehicle_type 39.0 4486197526664593040 \n", + "362910 unknown_vehicle_type 30.0 3388798362605091248 \n", + "397490 unknown_vehicle_type 46.0 17748416797468343771 \n", + "646286 unknown_vehicle_type 61.0 1096586971710081424 \n", + "432031 unknown_vehicle_type 58.0 17878107943481256906 \n", "\n", - " previous_trip_purpose trip_taker_building_type transit_submode \\\n", - "553553 home single_family NaN \n", - "279158 home single_family NaN \n", - "181137 work single_family NaN \n", - "287640 eat single_family NaN \n", - "626533 recreation single_family NaN \n", + " destination_bgrp_2020 destination_building_use \\\n", + "199078 2 (Tract 105, San Francisco, CA) non_retail_attraction \n", + "362910 1 (Tract 3551.13, Contra Costa, CA) single_family \n", + "397490 5 (Tract 4381, Alameda, CA) multi_family \n", + "646286 1 (Tract 177, San Francisco, CA) retail \n", + "432031 3 (Tract 151, San Francisco, CA) office \n", + "\n", + " trip_taker_wfh destination_st_2020 \\\n", + "199078 in_person California \n", + "362910 in_person California \n", + "397490 in_person California \n", + "646286 unemployed_under_16_not_in_labor_force California \n", + "432031 in_person California \n", + "\n", + " destination_cty_2020 trip_taker_work_bgrp_2020 \\\n", + "199078 San Francisco 2 (Tract 105, San Francisco, CA) \n", + "362910 Contra Costa 1 (Tract 615.01, San Francisco, CA) \n", + "397490 Alameda 3 (Tract 301.02, San Francisco, CA) \n", + "646286 San Francisco Does not have work/school location \n", + "432031 San Francisco 3 (Tract 151, San Francisco, CA) \n", + "\n", + " destination_trct_2020 trip_taker_household_income \\\n", + "199078 105 (San Francisco, CA) 237966.0 \n", + "362910 3551.13 (Contra Costa, CA) 237586.0 \n", + "397490 4381 (Alameda, CA) 101548.0 \n", + "646286 177 (San Francisco, CA) 163758.0 \n", + "432031 151 (San Francisco, CA) 191291.0 \n", + "\n", + " origin_bgrp_2020 trip_taker_commute_mode \\\n", + "199078 2 (Tract 4501.01, Alameda, CA) public_transit \n", + "362910 1 (Tract 615.06, San Francisco, CA) walking \n", + "397490 3 (Tract 301.02, San Francisco, CA) private_auto \n", + "646286 2 (Tract 3851, Contra Costa, CA) other_travel_mode \n", + "432031 1 (Tract 3790, Contra Costa, CA) private_auto \n", + "\n", + " trip_taker_available_vehicles primary_mode previous_trip_purpose \\\n", + "199078 one auto_passenger home \n", + "362910 one auto_passenger home \n", + "397490 two private_auto work \n", + "646286 two auto_passenger home \n", + "432031 two auto_passenger home \n", + "\n", + " trip_taker_building_type transit_submode \\\n", + "199078 multiple_units NaN \n", + "362910 multiple_units NaN \n", + "397490 several_units NaN \n", + "646286 single_family NaN \n", + "432031 single_family NaN \n", "\n", " trip_taker_work_st_2020 trip_taker_household_size \\\n", - "553553 California 4.0 \n", - "279158 Does not have work/school location 2.0 \n", - "181137 California 3.0 \n", - "287640 Does not have work/school location 5.0 \n", - "626533 Does not have work/school location 2.0 \n", + "199078 California 4.0 \n", + "362910 California 2.0 \n", + "397490 California 4.0 \n", + "646286 Does not have work/school location 4.0 \n", + "432031 California 3.0 \n", "\n", " origin_cty_2020 destination_land_use trip_taker_industry \\\n", - "553553 Contra Costa office naics54 \n", - "279158 Alameda non_retail_attraction not_working \n", - "181137 San Francisco single_family naics31_33 \n", - "287640 San Francisco single_family not_working \n", - "626533 San Mateo single_family not_working \n", + "199078 Alameda non_retail_attraction naics31_33 \n", + "362910 San Francisco single_family naics5151 \n", + "397490 San Francisco multi_family naics61 \n", + "646286 Contra Costa mixed_use not_working \n", + "432031 Contra Costa mixed_use naics42 \n", "\n", " trip_taker_tenure vehicle_fuel_type trip_taker_home_trct_2020 \\\n", - "553553 owner unknown_fuel_type 3551.25 (Contra Costa, CA) \n", - "279158 owner other_non_bev 4230 (Alameda, CA) \n", - "181137 owner unknown_fuel_type 4094 (Alameda, CA) \n", - "287640 owner unknown_fuel_type 2529.08 (Solano, CA) \n", - "626533 owner other_non_bev 2521.08 (Solano, CA) \n", + "199078 renter unknown_fuel_type 4501.01 (Alameda, CA) \n", + "362910 renter unknown_fuel_type 615.06 (San Francisco, CA) \n", + "397490 owner other_non_bev 4381 (Alameda, CA) \n", + "646286 owner unknown_fuel_type 3851 (Contra Costa, CA) \n", + "432031 owner unknown_fuel_type 3790 (Contra Costa, CA) \n", "\n", " trip_taker_work_trct_2020 trip_taker_education \\\n", - "553553 117 (San Francisco, CA) advanced_degree \n", - "279158 Does not have work/school location bachelors_degree \n", - "181137 111.02 (San Francisco, CA) high_school \n", - "287640 Does not have work/school location high_school \n", - "626533 Does not have work/school location advanced_degree \n", + "199078 105 (San Francisco, CA) advanced_degree \n", + "362910 615.01 (San Francisco, CA) bachelors_degree \n", + "397490 301.02 (San Francisco, CA) some_college \n", + "646286 Does not have work/school location high_school \n", + "432031 151 (San Francisco, CA) some_college \n", "\n", " trip_start_time trip_taker_individual_income \\\n", - "553553 07:05:00 171281.0 \n", - "279158 13:29:00 0.0 \n", - "181137 15:00:00 25705.0 \n", - "287640 22:41:00 0.0 \n", - "626533 20:33:00 91849.0 \n", + "199078 04:53:00 237966.0 \n", + "362910 17:25:00 77510.0 \n", + "397490 20:53:05 71051.0 \n", + "646286 17:10:00 11123.0 \n", + "432031 13:50:00 81981.0 \n", "\n", " trip_taker_employment_status trip_purpose origin_land_use \\\n", - "553553 employed work single_family \n", - "279158 not_in_labor_force recreation single_family \n", - "181137 employed home mixed_use \n", - "287640 not_in_labor_force home mixed_use \n", - "626533 not_in_labor_force home mixed_use \n", + "199078 employed work multi_family \n", + "362910 employed social mixed_use \n", + "397490 employed home education \n", + "646286 not_in_labor_force eat single_family \n", + "432031 employed work single_family \n", "\n", " trip_taker_work_cty_2020 trip_distance_miles \\\n", - "553553 San Francisco 39.7 \n", - "279158 Does not have work/school location 11.7 \n", - "181137 San Francisco 18.3 \n", - "287640 Does not have work/school location 57.2 \n", - "626533 Does not have work/school location 53.6 \n", + "199078 San Francisco 36.7 \n", + "362910 San Francisco 33.7 \n", + "397490 San Francisco 34.1 \n", + "646286 Does not have work/school location 17.5 \n", + "432031 San Francisco 18.4 \n", "\n", " trip_taker_school_grade_attending trip_taker_home_cty_2020 \\\n", - "553553 not_attending_school Contra Costa \n", - "279158 not_attending_school Alameda \n", - "181137 not_attending_school Alameda \n", - "287640 not_attending_school Solano \n", - "626533 not_attending_school Solano \n", + "199078 not_attending_school Alameda \n", + "362910 not_attending_school San Francisco \n", + "397490 not_attending_school Alameda \n", + "646286 not_attending_school Contra Costa \n", + "432031 not_attending_school Contra Costa \n", "\n", " trip_taker_person_id trip_end_time \n", - "553553 10449641475948959375 07:59:40 \n", - "279158 17632012171564480054 13:51:00 \n", - "181137 13577701224844795977 15:33:51 \n", - "287640 10756826488872628366 23:51:07 \n", - "626533 1309500236464925123 21:38:12 " + "199078 11699013211020046684 05:39:20 \n", + "362910 14279596460102489210 18:30:49 \n", + "397490 9371860226741686287 21:46:49 \n", + "646286 15224202816917079679 17:52:23 \n", + "432031 17663033273047637228 14:20:30 " ] }, "execution_count": 9, @@ -787,7 +794,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 13, "id": "05893215-e993-44dc-9c4b-1aa7d94815cd", "metadata": {}, "outputs": [ @@ -796,23 +803,23 @@ "text/html": [ "\n", "\n", - "
\n", + "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, - "execution_count": 74, + "execution_count": 47, "metadata": {}, "output_type": "execute_result" } @@ -2486,7 +2196,7 @@ }, { "cell_type": "code", - "execution_count": 75, + "execution_count": 48, "id": "60df338f-801f-49a1-a26f-0be5e03bddf3", "metadata": {}, "outputs": [ @@ -2560,131 +2270,206 @@ "75 AC TRANSIT, San Francisco Municipal Transportation Agency" ] }, - "execution_count": 75, + "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "display(HTML(\"

Most Common Agency Combination

\")) \n", - "\n", - "(df>>arrange(-_.n)>>select(_.transit_agency)).head(5)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "786394ef-be26-4e0d-94e7-35386d6d67c0", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "fd43ab95-0391-407b-b6b0-185034ba9528", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 76, - "id": "8af03d60-4537-44d3-b82f-d857625e47c3", - "metadata": {}, - "outputs": [], - "source": [ - "columns_to_keep = [\"AC TRANSIT\",\n", - " \"San Francisco Bay Ferry\",\n", - " \"SolTrans\",\n", - " \"Caltrain\",\n", - " \"SamTrans\",\n", - " \"The S\",\n", - " \"Fairfield and Suisun Transit\",\n", - " \"Sacramento Regional Transit\",\n", - " \"Marin Transit\",\n", - " \"Tri Delta Transit\",\n", - " \"San Francisco Municipal Transportation Agency\",\n", - " \"Amtrak\",\n", - " \"San Joaquin Regional Transit District (RTD)\",\n", - " \"Bay Area Rapid Transit\",\n", - " \"Santa Cruz Metro\",\n", - " \"VTA\"\n", - " ]" - ] - }, - { - "cell_type": "code", - "execution_count": 77, - "id": "6951b590-cef8-44bd-b27d-0b18893609c5", - "metadata": {}, - "outputs": [], - "source": [ - "# agency_indv_count.sample()" - ] - }, - { - "cell_type": "code", - "execution_count": 78, - "id": "cca56d58-5e3f-430c-adde-15ca665d46f8", - "metadata": {}, - "outputs": [], - "source": [ - "df_agencies = agency_indv_count.loc[:, columns_to_keep]" + "display(HTML(\"

Most Common Agency Combination

\")) \n", + "\n", + "(df>>arrange(-_.n)>>select(_.transit_agency)).head(5)" ] }, { "cell_type": "code", - "execution_count": 79, - "id": "814dde3a-d303-4044-9df1-464e408bf460", + "execution_count": null, + "id": "786394ef-be26-4e0d-94e7-35386d6d67c0", "metadata": {}, "outputs": [], - "source": [ - "df_agencies = pd.DataFrame(df_agencies).transpose().reset_index().rename(columns={'index':'agency'})" - ] + "source": [] }, { "cell_type": "code", - "execution_count": 80, - "id": "84174911-2243-430c-ab73-1fecb2552094", + "execution_count": null, + "id": "fd43ab95-0391-407b-b6b0-185034ba9528", "metadata": {}, "outputs": [], - "source": [ - "# df_agencies" - ] + "source": [] }, { "cell_type": "code", - "execution_count": 81, - "id": "202923d2-b869-4a72-8a02-ce229a65d815", + "execution_count": 49, + "id": "8af03d60-4537-44d3-b82f-d857625e47c3", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "/tmp/ipykernel_634/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:102: 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": 82, - "id": "2b31eb23-e1e6-43c6-8b0e-ccb3802cd09d", + "execution_count": 50, + "id": "6951b590-cef8-44bd-b27d-0b18893609c5", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
agencyn_trips
0Sacramento Regional Transit6
1SamTrans19
2nan1
3The S3
4San Francisco Municipal Transportation Agency175
5Caltrain20
6Marin Transit1
7Tri Delta Transit1
8Santa Cruz Metro1
9VTA16
10Fairfield and Suisun Transit1
11San Joaquin Regional Transit District (RTD)0
12SolTrans29
13San Francisco Bay Ferry3
14AC TRANSIT111
15Bay Area Rapid Transit37
16Amtrak10
\n", + "
" + ], + "text/plain": [ + " agency n_trips\n", + "0 Sacramento Regional Transit 6\n", + "1 SamTrans 19\n", + "2 nan 1\n", + "3 The S 3\n", + "4 San Francisco Municipal Transportation Agency 175\n", + "5 Caltrain 20\n", + "6 Marin Transit 1\n", + "7 Tri Delta Transit 1\n", + "8 Santa Cruz Metro 1\n", + "9 VTA 16\n", + "10 Fairfield and Suisun Transit 1\n", + "11 San Joaquin Regional Transit District (RTD) 0\n", + "12 SolTrans 29\n", + "13 San Francisco Bay Ferry 3\n", + "14 AC TRANSIT 111\n", + "15 Bay Area Rapid Transit 37\n", + "16 Amtrak 10" + ] + }, + "execution_count": 50, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "df_agencies = df_agencies>>select(_.agency, _.n_trips)" + "df_agencies" ] }, { "cell_type": "code", - "execution_count": 83, + "execution_count": 51, "id": "f98c76b9-b83f-42c3-aa12-702ade72ac38", "metadata": {}, "outputs": [], @@ -2694,7 +2479,7 @@ }, { "cell_type": "code", - "execution_count": 84, + "execution_count": 52, "id": "f1267faf-e28c-4208-ae79-43b31f67f705", "metadata": {}, "outputs": [], @@ -2704,7 +2489,7 @@ }, { "cell_type": "code", - "execution_count": 85, + "execution_count": 53, "id": "bf160b81-1bc2-4374-9529-6400252d5e4f", "metadata": {}, "outputs": [ @@ -2713,23 +2498,23 @@ "text/html": [ "\n", "\n", - "
\n", + "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, - "execution_count": 85, + "execution_count": 53, "metadata": {}, "output_type": "execute_result" } @@ -2820,7 +2605,7 @@ }, { "cell_type": "code", - "execution_count": 86, + "execution_count": 54, "id": "16b45917-adc3-44d0-8d76-15ccd4083d26", "metadata": {}, "outputs": [ @@ -2843,7 +2628,7 @@ }, { "cell_type": "code", - "execution_count": 87, + "execution_count": 55, "id": "5163926e-82bd-4c25-9486-45229d09a0d1", "metadata": {}, "outputs": [], @@ -2856,7 +2641,7 @@ }, { "cell_type": "code", - "execution_count": 88, + "execution_count": 56, "id": "636e7771-0ba7-42e9-af1d-e3e998ff8599", "metadata": {}, "outputs": [ @@ -2958,7 +2743,7 @@ "8 public_transit visitor 47" ] }, - "execution_count": 88, + "execution_count": 56, "metadata": {}, "output_type": "execute_result" } @@ -2969,7 +2754,7 @@ }, { "cell_type": "code", - "execution_count": 89, + "execution_count": 57, "id": "90c5d683-91c5-4663-accd-4e45027a3e49", "metadata": {}, "outputs": [ @@ -2978,23 +2763,23 @@ "text/html": [ "\n", "\n", - "
\n", + "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, - "execution_count": 53, + "execution_count": 56, "metadata": {}, "output_type": "execute_result" } @@ -2833,7 +2900,7 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 57, "id": "60df338f-801f-49a1-a26f-0be5e03bddf3", "metadata": {}, "outputs": [ @@ -2907,7 +2974,7 @@ "1 Metro - Los Angeles" ] }, - "execution_count": 54, + "execution_count": 57, "metadata": {}, "output_type": "execute_result" } @@ -2944,7 +3011,7 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 58, "id": "96b794f2-bcfd-4afb-9ce5-8793c15fe199", "metadata": {}, "outputs": [ @@ -2952,7 +3019,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "/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", + "/home/jovyan/data-analyses/sb125_analyses/corridor_study/_utils.py:102: 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" ] } @@ -2963,7 +3030,7 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 59, "id": "80cbffde-6686-4921-b543-84e52f97a0c5", "metadata": {}, "outputs": [ @@ -2995,83 +3062,83 @@ " \n", " \n", " 0\n", - " Culver CityBus\n", - " 28\n", + " Foothill Transit\n", + " 1\n", " \n", " \n", " 1\n", - " Foothill Transit\n", - " 1\n", + " LADOTMVS\n", + " 4\n", " \n", " \n", " 2\n", - " LA Go Bus\n", - " 1\n", + " LADOTMVN\n", + " 54\n", " \n", " \n", " 3\n", - " Metro - Los Angeles\n", - " 195\n", + " AVTA\n", + " 4\n", " \n", " \n", " 4\n", - " Amtrak\n", - " 8\n", + " Beach Cities Transit-City of Redondo Beach\n", + " 2\n", " \n", " \n", " 5\n", - " AVTA\n", - " 4\n", + " Metro - Los Angeles\n", + " 195\n", " \n", " \n", " 6\n", - " GTrans\n", + " Long Beach Transit\n", " 1\n", " \n", " \n", " 7\n", - " Metrolink Trains\n", - " 1\n", + " LADOT126\n", + " 4\n", " \n", " \n", " 8\n", - " LADOTMVN\n", - " 54\n", + " Santa Clarita Transit\n", + " 28\n", " \n", " \n", " 9\n", - " Long Beach Transit\n", + " Metrolink Trains\n", " 1\n", " \n", " \n", " 10\n", - " Santa Clarita Transit\n", - " 28\n", + " LADOTDT\n", + " 3\n", " \n", " \n", " 11\n", - " LADOTDT\n", - " 3\n", + " Culver CityBus\n", + " 28\n", " \n", " \n", " 12\n", - " Big Blue Bus\n", - " 37\n", + " GTrans\n", + " 1\n", " \n", " \n", " 13\n", - " LADOT126\n", - " 4\n", + " Amtrak\n", + " 8\n", " \n", " \n", " 14\n", - " LADOTMVS\n", - " 4\n", + " LA Go Bus\n", + " 1\n", " \n", " \n", " 15\n", - " Beach Cities Transit-City of Redondo Beach\n", - " 2\n", + " Big Blue Bus\n", + " 37\n", " \n", " \n", "\n", @@ -3079,25 +3146,25 @@ ], "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" + "0 Foothill Transit 1\n", + "1 LADOTMVS 4\n", + "2 LADOTMVN 54\n", + "3 AVTA 4\n", + "4 Beach Cities Transit-City of Redondo Beach 2\n", + "5 Metro - Los Angeles 195\n", + "6 Long Beach Transit 1\n", + "7 LADOT126 4\n", + "8 Santa Clarita Transit 28\n", + "9 Metrolink Trains 1\n", + "10 LADOTDT 3\n", + "11 Culver CityBus 28\n", + "12 GTrans 1\n", + "13 Amtrak 8\n", + "14 LA Go Bus 1\n", + "15 Big Blue Bus 37" ] }, - "execution_count": 56, + "execution_count": 59, "metadata": {}, "output_type": "execute_result" } @@ -3108,7 +3175,7 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 60, "id": "f98c76b9-b83f-42c3-aa12-702ade72ac38", "metadata": {}, "outputs": [], @@ -3118,7 +3185,7 @@ }, { "cell_type": "code", - "execution_count": 59, + "execution_count": 61, "id": "bf160b81-1bc2-4374-9529-6400252d5e4f", "metadata": {}, "outputs": [ @@ -3127,23 +3194,23 @@ "text/html": [ "\n", "\n", - "
\n", + "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, - "execution_count": 59, + "execution_count": 61, "metadata": {}, "output_type": "execute_result" } @@ -3226,7 +3293,7 @@ }, { "cell_type": "code", - "execution_count": 60, + "execution_count": 62, "id": "16b45917-adc3-44d0-8d76-15ccd4083d26", "metadata": {}, "outputs": [ @@ -3249,7 +3316,7 @@ }, { "cell_type": "code", - "execution_count": 61, + "execution_count": 63, "id": "5163926e-82bd-4c25-9486-45229d09a0d1", "metadata": {}, "outputs": [], @@ -3262,7 +3329,7 @@ }, { "cell_type": "code", - "execution_count": 62, + "execution_count": 64, "id": "636e7771-0ba7-42e9-af1d-e3e998ff8599", "metadata": {}, "outputs": [ @@ -3385,7 +3452,7 @@ "11 public_transit visitor 56" ] }, - "execution_count": 62, + "execution_count": 64, "metadata": {}, "output_type": "execute_result" } @@ -3396,7 +3463,7 @@ }, { "cell_type": "code", - "execution_count": 63, + "execution_count": 65, "id": "90c5d683-91c5-4663-accd-4e45027a3e49", "metadata": {}, "outputs": [ @@ -3405,23 +3472,23 @@ "text/html": [ "\n", "\n", - "
\n", + "
\n", "