From 23342ac8ac75dcce2f7b5ef2c26d5e29adeab750 Mon Sep 17 00:00:00 2001 From: itsGarrin Date: Sun, 5 Nov 2023 20:27:58 -0500 Subject: Continued work on the Zesty Salesman algorithm --- ZestySalesman.ipynb | 167 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 110 insertions(+), 57 deletions(-) (limited to 'ZestySalesman.ipynb') diff --git a/ZestySalesman.ipynb b/ZestySalesman.ipynb index fb03d13..7e74f46 100644 --- a/ZestySalesman.ipynb +++ b/ZestySalesman.ipynb @@ -2,13 +2,13 @@ "cells": [ { "cell_type": "code", - "execution_count": 62, + "execution_count": 10, "id": "initial_id", "metadata": { "collapsed": true, "ExecuteTime": { - "end_time": "2023-11-06T00:26:14.565659Z", - "start_time": "2023-11-06T00:26:14.551906Z" + "end_time": "2023-11-06T01:23:16.767323Z", + "start_time": "2023-11-06T01:23:16.761053Z" } }, "outputs": [], @@ -16,107 +16,104 @@ "import pandas as pd\n", "import numpy as np\n", "import requests\n", - "import folium" + "import folium\n", + "import utils" ] }, { "cell_type": "code", - "execution_count": 63, + "execution_count": 11, "outputs": [], "source": [ "# Create a JSON request for the API\n", "# This is the data we want to get from the API\n", "northeastern_coordinate = \"-71.09033,42.33976;\"\n", - "coordinate_string = '-71.2038948,42.4299758;-71.1060828,42.3511927;-71.0969274,42.3446263;-71.130887,42.35304;-71.1459593,42.3501823;-71.1460435,42.3495825;-71.1217152,42.3426377;-71.1258765,42.331864;-71.1095021,42.3364675;-71.133103,42.3890049;-71.0851891,42.3500031;-71.1123834,42.3360385;-71.2273649,42.3145041;-71.0834061,42.341987;-71.0992038,42.3306454;-71.0990577,42.3381442;-71.0949218,42.3419564;-71.0942861,42.3413301;-71.0908104,42.329969;-71.0913583,42.3490205;-71.1000217,42.3323776;-71.1241295,42.3518397;-71.1618052,42.3245965;-71.1625829,42.340795;-71.167854,42.4107892;-71.155555,42.3317473;-71.1227278,42.3965778;-71.3598149,42.3140229;-71.1126695,42.3836229;-71.119149,42.3884;-71.0872846,42.2961434;-71.1427371,42.3433772;-71.1438455,42.3569102;-71.1313443,42.3525708;-71.1284677,42.3631904;-71.119301,42.388547;-71.097883,42.381008;-71.1107166,42.3741209;-71.1194344,42.3754427;-71.1013044,42.3627462;-71.1108423,42.3838224;-71.1026937,42.3820702;-71.1189467,42.373465;-71.1208817,42.3732344;-71.0968274,42.3799095;-71.094048,42.339381;-71.1854722,42.3621177;-71.1146697,42.3782386;-71.0935443,42.3817274;-71.0906355,42.3616095;-71.1161887,42.3766442;-71.0962734,42.3627993;-71.1155576,42.3784629;-71.0949101,42.3797674;-71.1087411,42.3640287;-71.09476,42.37736;-71.1014951,42.3614115;-71.1024769,42.3822934;-71.1011111,42.3636597;-71.0898829,42.3463992;-71.0983169,42.3319001;-71.0945712,42.3253252;-71.1122037,42.4008442'\n", - "coordinates = requests.get('http://acetyl.net:5000/trip/v1/bike/' + northeastern_coordinate + coordinate_string)\n", - "\n", - "coordinates = coordinates.json()" + "route_1 = '-71.2038948,42.4299758;-71.1060828,42.3511927;-71.0969274,42.3446263;-71.130887,42.35304;-71.1459593,42.3501823;-71.1460435,42.3495825;-71.1217152,42.3426377;-71.1258765,42.331864;-71.1095021,42.3364675;-71.133103,42.3890049;-71.1123834,42.3360385;-71.2273649,42.3145041;-71.0992038,42.3306454;-71.0990577,42.3381442;-71.0949218,42.3419564;-71.0942861,42.3413301;-71.0913583,42.3490205;-71.1000217,42.3323776;-71.1241295,42.3518397;-71.1618052,42.3245965;-71.1625829,42.340795;-71.167854,42.4107892;-71.155555,42.3317473;-71.1227278,42.3965778;-71.1126695,42.3836229;-71.119149,42.3884;-71.1427371,42.3433772;-71.1438455,42.3569102;-71.1313443,42.3525708;-71.1284677,42.3631904;-71.119301,42.388547;-71.097883,42.381008;-71.1107166,42.3741209;-71.1194344,42.3754427;-71.1013044,42.3627462;-71.1108423,42.3838224;-71.1026937,42.3820702;-71.1189467,42.373465;-71.1208817,42.3732344;-71.0968274,42.3799095;-71.094048,42.339381;-71.1854722,42.3621177;-71.1146697,42.3782386;-71.0935443,42.3817274;-71.0906355,42.3616095;-71.1161887,42.3766442;-71.0962734,42.3627993;-71.1155576,42.3784629;-71.0949101,42.3797674;-71.1087411,42.3640287;-71.09476,42.37736;-71.1014951,42.3614115;-71.1024769,42.3822934;-71.1011111,42.3636597;-71.0898829,42.3463992;-71.0983169,42.3319001'\n", + "route_2 = '-71.0553792,42.3688272;-71.0688746,42.3576234;-71.0754527,42.3565057;-71.0620802,42.3579151;-71.0586014,42.357357;-71.0572023,42.3587627;-71.0556268,42.36521;-71.0720926,42.3489004;-71.067859,42.3500079;-71.0632036,42.3556154;-71.0620134,42.3248471;-71.0851891,42.3500031;-71.066414,42.354296;-71.0834061,42.341987;-71.0569649,42.3604952;-71.0498714,42.3256817;-71.0908104,42.329969;-71.0616035,42.3537983;-71.0359433,42.3485465;-71.0638101,42.3587772;-71.0555003,42.3640137;-71.0712561,42.3407613;-71.0561781,42.3668968;-71.0664019,42.3554589;-71.059228,42.359349;-71.0668408,42.3524116;-71.0872846,42.2961434;-71.062146,42.366198;-71.0651214,42.3553972;-71.0596124,42.3509517;-71.0359354,42.3478381;-71.061757,42.3691906;-71.0609962,42.3803747;-71.0516339,42.3609921;-71.0809932,42.3675275;-71.0545357,42.3597994;-71.0342146,42.316274;-71.0756902,42.3695046;-71.0678704,42.3701829;-71.0656594,42.3718401;-71.0611749,42.3551807;-71.0554239,42.3739796;-71.0631664,42.3741694;-71.056823,42.361531;-71.0632852,42.2857047;-71.0637877,42.2845163;-71.0496839,42.3519736;-71.0454645,42.3162356;-71.0336324,42.3441918;-71.0487437,42.3508756;-71.0512911,42.3521821;-71.0013637,42.2075316;-71.0607764,42.3763541;-71.0374911,42.316031;-71.0125206,42.3378699;-71.0672898,42.3523158;-71.02832,42.2576602;-71.0502126,42.3516479;-71.0331956,42.3639107;-71.0432778,42.3528151;-71.0035279,42.2392354;-71.0470633,42.3537343;-71.0352443,42.3291218;-71.0240951,42.2743442;-71.0234949,42.3358743;-70.985881,42.420226;-71.0005483,42.2454086;-71.0096371,42.3367603;-71.0447796,42.3509709;-71.0092883,42.2763168;-71.0404428,42.3478375;-71.056908,42.361288;-71.0667744,42.3270498;-71.0119933,42.2806539'" ], "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-11-06T00:26:15.268775Z", - "start_time": "2023-11-06T00:26:14.558083Z" + "end_time": "2023-11-06T01:23:16.774149Z", + "start_time": "2023-11-06T01:23:16.765417Z" } }, "id": "aa618161182b5b07" }, { "cell_type": "code", - "execution_count": 64, + "execution_count": 12, "outputs": [], "source": [ "# Create a dataframe from the JSON\n", - "df = pd.DataFrame(coordinates['waypoints'])" + "df1 = utils.create_json_df(northeastern_coordinate + route_1)\n", + "df2 = utils.create_json_df(northeastern_coordinate + route_2)" ], "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-11-06T00:26:15.278022Z", - "start_time": "2023-11-06T00:26:15.269158Z" + "end_time": "2023-11-06T01:23:18.694403Z", + "start_time": "2023-11-06T01:23:16.768656Z" } }, "id": "32c485788eedd94" }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 13, "outputs": [], "source": [ - "# Separate the location column into lon and lat columns\n", - "df['lat'] = df['location'].apply(lambda x: x[0])\n", - "df['lon'] = df['location'].apply(lambda x: x[1])\n", - "\n", - "df['waypoint_index'] = df['waypoint_index'].astype(int)\n", + "# Add columns for the route number\n", + "df1['route'] = 1\n", + "df2['route'] = 2\n", "\n", - "# Map out the waypoints in order of the waypoint index\n", - "df = df.sort_values(by=['waypoint_index'])" + "# Concatenate the two dataframes\n", + "df = pd.concat([df1, df2], ignore_index=True)" ], "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-11-06T00:26:15.284313Z", - "start_time": "2023-11-06T00:26:15.275568Z" + "end_time": "2023-11-06T01:23:18.698699Z", + "start_time": "2023-11-06T01:23:18.696008Z" } }, - "id": "535ab02638d20cb2" + "id": "49dba1f17ca8337e" }, { "cell_type": "code", - "execution_count": 66, + "execution_count": 14, "outputs": [ { "data": { - "text/plain": " waypoint_index trips_index \\\n0 0 0 \n14 1 0 \n60 2 0 \n46 3 0 \n16 4 0 \n.. ... ... \n61 59 0 \n15 60 0 \n19 61 0 \n31 62 0 \n62 63 0 \n\n hint distance \\\n0 DoUhgBeFIYCcAAAAJgAAAAAAAAARAAAAm0CKQdkZiEAAAA... 0.236958 \n14 lhgDgIkYA4BkAAAAIgEAAFoBAAAaAAAAJyAzQWNrAEI8Ax... 7.134933 \n60 tg0igLoNIoAOAAAAAAAAADwAAADtAQAA8CrBQAAAAACcrM... 17.496916 \n46 k4chgBiIIYAKAAAAFwAAAPQDAAB_AgAAHn2aP-biHUBi6e... 36.240351 \n16 rLwhgLG8IYAEAAAABQAAADAAAABsAAAA1X8CQHGb7D9Kz6... 24.054372 \n.. ... ... \n61 g38hgI1_IYBOAAAAfwAAAAAAAAAAAAAAZ4ECQsbEUkIAAA... 12.789906 \n15 cX8hgJF_IYA1AAAAMAAAAGcAAABOAAAATyWxQQ77nUEHMC... 22.776295 \n19 5tYhgJHXIYAIAAAArQAAADwAAABCAQAAaRlbQD16mUGpAc... 17.374491 \n31 WhEngAASJ4BcAAAAdwAAAHoBAAAFAAAAI3gkQQlZRUJLNi... 13.907079 \n62 s9QhgLbUIYAwAAAAkAAAAAAAAAAAAAAA2XmpQNgrgEEAAA... 4.111715 \n\n name location lat lon \n0 Northeastern (Inbound) [-71.090331, 42.339762] -71.090331 42.339762 \n14 [-71.083465, 42.34194] -71.083465 42.341940 \n60 Public Alley 901 [-71.089677, 42.346361] -71.089677 42.346361 \n46 [-71.093834, 42.339096] -71.093834 42.339096 \n16 [-71.099284, 42.338007] -71.099284 42.338007 \n.. ... ... ... ... \n61 Tremont Street [-71.098267, 42.332009] -71.098267 42.332009 \n15 Alleghany Street [-71.099348, 42.33047] -71.099348 42.330470 \n19 Dudley Street [-71.090904, 42.329829] -71.090904 42.329829 \n31 Blue Hill Avenue [-71.087449, 42.296172] -71.087449 42.296172 \n62 [-71.09454, 42.325354] -71.094540 42.325354 \n\n[64 rows x 8 columns]", - "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 \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
waypoint_indextrips_indexhintdistancenamelocationlatlon
000DoUhgBeFIYCcAAAAJgAAAAAAAAARAAAAm0CKQdkZiEAAAA...0.236958Northeastern (Inbound)[-71.090331, 42.339762]-71.09033142.339762
1410lhgDgIkYA4BkAAAAIgEAAFoBAAAaAAAAJyAzQWNrAEI8Ax...7.134933[-71.083465, 42.34194]-71.08346542.341940
6020tg0igLoNIoAOAAAAAAAAADwAAADtAQAA8CrBQAAAAACcrM...17.496916Public Alley 901[-71.089677, 42.346361]-71.08967742.346361
4630k4chgBiIIYAKAAAAFwAAAPQDAAB_AgAAHn2aP-biHUBi6e...36.240351[-71.093834, 42.339096]-71.09383442.339096
1640rLwhgLG8IYAEAAAABQAAADAAAABsAAAA1X8CQHGb7D9Kz6...24.054372[-71.099284, 42.338007]-71.09928442.338007
...........................
61590g38hgI1_IYBOAAAAfwAAAAAAAAAAAAAAZ4ECQsbEUkIAAA...12.789906Tremont Street[-71.098267, 42.332009]-71.09826742.332009
15600cX8hgJF_IYA1AAAAMAAAAGcAAABOAAAATyWxQQ77nUEHMC...22.776295Alleghany Street[-71.099348, 42.33047]-71.09934842.330470
196105tYhgJHXIYAIAAAArQAAADwAAABCAQAAaRlbQD16mUGpAc...17.374491Dudley Street[-71.090904, 42.329829]-71.09090442.329829
31620WhEngAASJ4BcAAAAdwAAAHoBAAAFAAAAI3gkQQlZRUJLNi...13.907079Blue Hill Avenue[-71.087449, 42.296172]-71.08744942.296172
62630s9QhgLbUIYAwAAAAkAAAAAAAAAAAAAAA2XmpQNgrgEEAAA...4.111715[-71.09454, 42.325354]-71.09454042.325354
\n

64 rows × 8 columns

\n
" + "text/plain": " waypoint_index trips_index \\\n0 0 0 \n17 1 0 \n22 2 0 \n73 3 0 \n11 4 0 \n.. ... ... \n3 70 0 \n12 71 0 \n9 72 0 \n8 73 0 \n14 74 0 \n\n hint distance \\\n0 DoUhgBeFIYCcAAAAJgAAAAAAAAARAAAAm0CKQdkZiEAAAA... 0.236958 \n17 5tYhgJHXIYAIAAAArQAAADwAAABCAQAAaRlbQD16mUGpAc... 17.374491 \n22 XAAigHIAIoBKAAAASwAAAFUAAABDAQAARGUEQURlBEG2ZR... 11.054154 \n73 CdQhgB0OA4AYAAAAHgAAADkAAAAAAAAALdMlQdSMQ0Fd0r... 10.970598 \n11 43YhgPN2IYA1AAAAJAAAAAAAAAA5AAAAEha0QWgpbEEAAA... 18.896385 \n.. ... ... \n3 jt4hgJLeIYA7AAAALQAAAAAAAAAAAAAA4gPGQasVlUEAAA... 4.709088 \n12 0OEhgPvhIYADAAAABgAAAA8AAAA0AAAA2lq-PipQFD-Y-N... 2.009578 \n9 m8shgJ7LIYAOAAAAXgEAAAAAAAAAAAAAOFW-QDE5G0IAAA... 1.716409 \n8 YQ0DgBTPIYDvAAAAdAAAAAAAAAAAAAAAsgLVQbMxTUEAAA... 4.830022 \n14 lhgDgIkYA4BkAAAAIgEAAFoBAAAaAAAAJyAzQWNrAEI8Ax... 7.134933 \n\n name location lat lon \\\n0 Northeastern (Inbound) [-71.090331, 42.339762] -71.090331 42.339762 \n17 Dudley Street [-71.090904, 42.329829] -71.090904 42.329829 \n22 [-71.071196, 42.34085] -71.071196 42.340850 \n73 [-71.066844, 42.327134] -71.066844 42.327134 \n11 Lucy Street [-71.06221, 42.324934] -71.062210 42.324934 \n.. ... ... ... ... \n3 [-71.075414, 42.356537] -71.075414 42.356537 \n12 [-71.085166, 42.349997] -71.085166 42.349997 \n9 Piedmont Street [-71.067854, 42.349993] -71.067854 42.349993 \n8 [-71.072038, 42.348915] -71.072038 42.348915 \n14 [-71.083465, 42.34194] -71.083465 42.341940 \n\n route \n0 2 \n17 2 \n22 2 \n73 2 \n11 2 \n.. ... \n3 2 \n12 2 \n9 2 \n8 2 \n14 2 \n\n[75 rows x 9 columns]", + "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 \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
waypoint_indextrips_indexhintdistancenamelocationlatlonroute
000DoUhgBeFIYCcAAAAJgAAAAAAAAARAAAAm0CKQdkZiEAAAA...0.236958Northeastern (Inbound)[-71.090331, 42.339762]-71.09033142.3397622
17105tYhgJHXIYAIAAAArQAAADwAAABCAQAAaRlbQD16mUGpAc...17.374491Dudley Street[-71.090904, 42.329829]-71.09090442.3298292
2220XAAigHIAIoBKAAAASwAAAFUAAABDAQAARGUEQURlBEG2ZR...11.054154[-71.071196, 42.34085]-71.07119642.3408502
7330CdQhgB0OA4AYAAAAHgAAADkAAAAAAAAALdMlQdSMQ0Fd0r...10.970598[-71.066844, 42.327134]-71.06684442.3271342
114043YhgPN2IYA1AAAAJAAAAAAAAAA5AAAAEha0QWgpbEEAAA...18.896385Lucy Street[-71.06221, 42.324934]-71.06221042.3249342
..............................
3700jt4hgJLeIYA7AAAALQAAAAAAAAAAAAAA4gPGQasVlUEAAA...4.709088[-71.075414, 42.356537]-71.07541442.3565372
127100OEhgPvhIYADAAAABgAAAA8AAAA0AAAA2lq-PipQFD-Y-N...2.009578[-71.085166, 42.349997]-71.08516642.3499972
9720m8shgJ7LIYAOAAAAXgEAAAAAAAAAAAAAOFW-QDE5G0IAAA...1.716409Piedmont Street[-71.067854, 42.349993]-71.06785442.3499932
8730YQ0DgBTPIYDvAAAAdAAAAAAAAAAAAAAAsgLVQbMxTUEAAA...4.830022[-71.072038, 42.348915]-71.07203842.3489152
14740lhgDgIkYA4BkAAAAIgEAAFoBAAAaAAAAJyAzQWNrAEI8Ax...7.134933[-71.083465, 42.34194]-71.08346542.3419402
\n

75 rows × 9 columns

\n
" }, - "execution_count": 66, "metadata": {}, - "output_type": "execute_result" + "output_type": "display_data" } ], "source": [ - "df" + "display(df2)" ], "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-11-06T00:26:15.297169Z", - "start_time": "2023-11-06T00:26:15.287354Z" + "end_time": "2023-11-06T01:23:18.708601Z", + "start_time": "2023-11-06T01:23:18.705324Z" } }, - "id": "49dba1f17ca8337e" + "id": "f231d9a35358988c" }, { "cell_type": "code", - "execution_count": 67, + "execution_count": 15, "outputs": [ { "data": { - "text/plain": "", - "text/html": "
Make this Notebook Trusted to load map: File -> Trust Notebook
" + "text/plain": "", + "text/html": "
Make this Notebook Trusted to load map: File -> Trust Notebook
" }, - "execution_count": 67, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -125,12 +122,14 @@ "# Create a map\n", "m = folium.Map(location=[df['lon'].mean(), df['lat'].mean()], zoom_start=11)\n", "\n", - "# Add a marker for each waypoint and connect with a line as the salesman would travel\n", - "for i in range(len(df)):\n", - " folium.Marker([df.iloc[i]['lon'], df.iloc[i]['lat']], popup=df.iloc[i]['name']).add_to(m)\n", - " if i < len(df) - 1:\n", - " folium.PolyLine([[df.iloc[i]['lon'], df.iloc[i]['lat']], [df.iloc[i + 1]['lon'], df.iloc[i + 1]['lat']]],\n", - " color=\"red\", weight=2.5, opacity=1).add_to(m)\n", + "# Add the points and lines for the two routes with different colors\n", + "colors = ['red', 'blue']\n", + "\n", + "for route in df['route'].unique():\n", + " df_route = df[df['route'] == route]\n", + " folium.PolyLine(df_route[['lon', 'lat']].values.tolist(), color=colors[route-1]).add_to(m)\n", + " for i in range(len(df_route)):\n", + " folium.CircleMarker(df_route[['lon', 'lat']].iloc[i].values.tolist(), radius=3, color=colors[route-1]).add_to(m)\n", "\n", "# Display the map\n", "m" @@ -138,50 +137,104 @@ "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-11-06T00:26:15.360267Z", - "start_time": "2023-11-06T00:26:15.298760Z" + "end_time": "2023-11-06T01:23:18.781393Z", + "start_time": "2023-11-06T01:23:18.709803Z" } }, "id": "80fd847da2833913" }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 16, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "The trip will take 10.198055555555555 hours\n" + "The trip will take 6.789722222222222 hours\n", + "The trip will take 9.955833333333333 hours\n" ] } ], "source": [ - "trip_hrs = int(coordinates['trips'][0]['duration'])/3600\n", - "print(\"The trip will take {} hours\".format(trip_hrs))" + "trip_hrs_1 = utils.get_trip_time(route_1)\n", + "print(\"The trip will take {} hours\".format(trip_hrs_1))\n", + "trip_hrs_2 = utils.get_trip_time(route_2)\n", + "print(\"The trip will take {} hours\".format(trip_hrs_2))" ], "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-11-06T00:26:15.360383Z", - "start_time": "2023-11-06T00:26:15.353591Z" + "end_time": "2023-11-06T01:23:20.448487Z", + "start_time": "2023-11-06T01:23:18.761079Z" } }, "id": "a3ec09dfb5cbb5b3" }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 17, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " waypoint_index trips_index \\\n", + "20 20 0 \n", + "\n", + " hint distance name \\\n", + "20 2M4pgNrOKYCCAQAADAAAAAAAAAAAAAAALKILQ27Ah0AAAA... 0.0 Echo Bridge \n", + "\n", + " location lat lon route \n", + "20 [-71.227365, 42.314504] -71.227365 42.314504 1 \n" + ] + } + ], + "source": [ + "# Find the westmost point in Route 1\n", + "df1 = df[df['route'] == 1]\n", + "west = df1[df1['lon'] == df1['lon'].min()]\n", + "print(west)" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2023-11-06T01:23:20.455714Z", + "start_time": "2023-11-06T01:23:20.453647Z" + } + }, + "id": "be94c3708a1bd250" + }, + { + "cell_type": "code", + "execution_count": 18, + "outputs": [], + "source": [ + "# Remove the westmost point from Route 1\n", + "df = df.drop(west.index)" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2023-11-06T01:23:20.460791Z", + "start_time": "2023-11-06T01:23:20.456599Z" + } + }, + "id": "21fef07e5b2a03a0" + }, + { + "cell_type": "code", + "execution_count": 18, "outputs": [], "source": [], "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-11-06T00:26:15.360410Z", - "start_time": "2023-11-06T00:26:15.355568Z" + "end_time": "2023-11-06T01:23:20.460900Z", + "start_time": "2023-11-06T01:23:20.458522Z" } }, - "id": "be94c3708a1bd250" + "id": "eafe5678c44e94fd" } ], "metadata": { -- cgit v1.2.3