{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "initial_id", "metadata": { "collapsed": true, "ExecuteTime": { "end_time": "2023-11-07T23:05:35.179983Z", "start_time": "2023-11-07T23:05:34.039783Z" } }, "outputs": [], "source": [ "import pandas as pd\n", "import folium\n", "import utils" ] }, { "cell_type": "code", "execution_count": 2, "outputs": [], "source": [ "# Load the data\n", "ListA = pd.read_csv('List A.csv')\n", "ListB = pd.read_csv('List B.csv')\n", "ListC = pd.read_csv('List C.csv')\n", "ListD = pd.read_csv('List D.csv')" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2023-11-07T23:05:35.194166Z", "start_time": "2023-11-07T23:05:35.181233Z" } }, "id": "73b780e762c9de37" }, { "cell_type": "code", "execution_count": 3, "outputs": [], "source": [ "# Create two centroids, one in the North End and one in the Seaport District\n", "centroids = [[42.365, -71.054], [42.351, -71.045]]\n", "\n", "northeastern_coordinate = \"-71.09033,42.33976\"" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2023-11-07T23:05:35.195314Z", "start_time": "2023-11-07T23:05:35.193156Z" } }, "id": "be4c8c1d77842ef7" }, { "cell_type": "code", "execution_count": 4, "outputs": [], "source": [ "# Combine the two lists and add a column to indicate the list\n", "ListA['list'] = 'A'\n", "ListB['list'] = 'B'\n", "ListC['list'] = 'C'\n", "ListD['list'] = 'D'\n", "\n", "TotalList = pd.concat([ListA, ListB, ListC, ListD])" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2023-11-07T23:05:35.201800Z", "start_time": "2023-11-07T23:05:35.197747Z" } }, "id": "ffe4025e97a6c6b9" }, { "cell_type": "code", "execution_count": 5, "outputs": [], "source": [ "# Remove all columns but name and gps\n", "TotalList = TotalList[['name', 'gps', 'list']]" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2023-11-07T23:05:35.215762Z", "start_time": "2023-11-07T23:05:35.200811Z" } }, "id": "72657779b4484aae" }, { "cell_type": "code", "execution_count": 6, "outputs": [], "source": [ "# Convert the gps column to a list of lists for k-means\n", "TotalList['gps'] = TotalList['gps'].apply(lambda x: x.strip('[]').split(','))\n", "TotalList['gps'] = TotalList['gps'].apply(lambda x: [float(i) for i in x])" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2023-11-07T23:05:35.215916Z", "start_time": "2023-11-07T23:05:35.204173Z" } }, "id": "a157ffaec020a29a" }, { "cell_type": "code", "execution_count": 7, "outputs": [ { "data": { "text/plain": " name gps list\n0 521 Commercial Street #525 [42.3688272, -71.0553792] A\n1 Acorn St [42.3576234, -71.0688746] A\n2 Arlington's Great Meadows [42.4299758, -71.2038948] A\n3 Arthur Fiedler Statue [42.3565057, -71.0754527] A\n4 BU Beach [42.3511927, -71.1060828] A\n.. ... ... ...\n33 The Quiet Few [42.3670906, -71.0359889] D\n34 The Tall Ship Boston [42.3649544, -71.0414523] D\n35 Toasted Flats [42.3711266, -71.0371343] D\n36 Vega Market [42.3891835, -71.033703] D\n37 Winthrop High School [42.3803348, -70.9799864] D\n\n[169 rows x 3 columns]", "text/html": "
| \n | name | \ngps | \nlist | \n
|---|---|---|---|
| 0 | \n521 Commercial Street #525 | \n[42.3688272, -71.0553792] | \nA | \n
| 1 | \nAcorn St | \n[42.3576234, -71.0688746] | \nA | \n
| 2 | \nArlington's Great Meadows | \n[42.4299758, -71.2038948] | \nA | \n
| 3 | \nArthur Fiedler Statue | \n[42.3565057, -71.0754527] | \nA | \n
| 4 | \nBU Beach | \n[42.3511927, -71.1060828] | \nA | \n
| ... | \n... | \n... | \n... | \n
| 33 | \nThe Quiet Few | \n[42.3670906, -71.0359889] | \nD | \n
| 34 | \nThe Tall Ship Boston | \n[42.3649544, -71.0414523] | \nD | \n
| 35 | \nToasted Flats | \n[42.3711266, -71.0371343] | \nD | \n
| 36 | \nVega Market | \n[42.3891835, -71.033703] | \nD | \n
| 37 | \nWinthrop High School | \n[42.3803348, -70.9799864] | \nD | \n
169 rows × 3 columns
\n| \n | waypoint_index | \ntrips_index | \nhint | \ndistance | \nname | \nlocation | \nlat | \nlon | \nroute | \n
|---|---|---|---|---|---|---|---|---|---|
| 0 | \n0 | \n0 | \n1IwsgDuNLIBFAAAAWgEAAA8AAAAAAAAAFQP1QGa9GUI7qN... | \n8.262982 | \n\n | [-71.053931, 42.365054] | \n-71.053931 | \n42.365054 | \n1 | \n
| 1 | \n1 | \n0 | \nG4gsgDiILICSAwAA5gAAAOkAAAAAAAAAQljLQnyXy0Fhy8... | \n2.602121 | \n\n | [-71.056164, 42.366918] | \n-71.056164 | \n42.366918 | \n1 | \n
| 2 | \n2 | \n0 | \ngIosgLaKLIDOAAAArgAAAFwBAAAAAAAAp3O3QafxmUEQiR... | \n15.458439 | \n\n | [-71.055561, 42.368861] | \n-71.055561 | \n42.368861 | \n1 | \n
| 3 | \n3 | \n0 | \nHpwsgCKcLIAAAAAAEgAAAAAAAAAAAAAAAAAAACg870AAAA... | \n39.201677 | \n\n | [-71.062507, 42.365968] | \n-71.062507 | \n42.365968 | \n1 | \n
| 4 | \n4 | \n0 | \nqn8sgKt_LIAfAAAAAAAAAAAAAAAAAAAA2ElcQAAAAAAAAA... | \n39.331841 | \n\n | [-71.064277, 42.358851] | \n-71.064277 | \n42.358851 | \n1 | \n
| ... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n
| 168 | \n61 | \n0 | \n7hAigPYQIoA2AgAAYwEAAAAAAAAAAAAAnsd7Qq9XHUIAAA... | \n7.478611 | \n\n | [-71.096959, 42.344689] | \n-71.096959 | \n42.344689 | \n2 | \n
| 169 | \n62 | \n0 | \nbwwigH0MIoAFAAAAEAAAAFUAAAArAAAAag0xP3921D-BFx... | \n8.340476 | \n\n | [-71.095003, 42.342001] | \n-71.095003 | \n42.342001 | \n2 | \n
| 170 | \n63 | \n0 | \nMQwigFwMIoAoAAAANQAAABwAAAB-AAAAoidqQSAYl0GvUh... | \n11.504463 | \n\n | [-71.094327, 42.341231] | \n-71.094327 | \n42.341231 | \n2 | \n
| 171 | \n64 | \n0 | \nk4chgBiIIYAKAAAAFwAAAPQDAAB_AgAAHn2aP-biHUBi6e... | \n36.240351 | \n\n | [-71.093834, 42.339096] | \n-71.093834 | \n42.339096 | \n2 | \n
| 172 | \n65 | \n0 | \nDoUhgBeFIYCcAAAAJgAAAAAAAAARAAAAm0CKQdkZiEAAAA... | \n0.236958 | \nNortheastern (Inbound) | \n[-71.090331, 42.339762] | \n-71.090331 | \n42.339762 | \n2 | \n
173 rows × 9 columns
\n| \n | waypoint_index | \ntrips_index | \nhint | \ndistance | \nname | \nlocation | \nlat | \nlon | \nroute | \n
|---|---|---|---|---|---|---|---|---|---|
| 0 | \n0 | \n0 | \n1IwsgDuNLIBFAAAAWgEAAA8AAAAAAAAAFQP1QGa9GUI7qN... | \n8.262982 | \n\n | [-71.053931, 42.365054] | \n-71.053931 | \n42.365054 | \n1 | \n
| 1 | \n1 | \n0 | \nG4gsgDiILICSAwAA5gAAAOkAAAAAAAAAQljLQnyXy0Fhy8... | \n2.602121 | \n\n | [-71.056164, 42.366918] | \n-71.056164 | \n42.366918 | \n1 | \n
| 2 | \n2 | \n0 | \ngIosgLaKLIDOAAAArgAAAFwBAAAAAAAAp3O3QafxmUEQiR... | \n15.458439 | \n\n | [-71.055561, 42.368861] | \n-71.055561 | \n42.368861 | \n1 | \n
| 3 | \n3 | \n0 | \nHpwsgCKcLIAAAAAAEgAAAAAAAAAAAAAAAAAAACg870AAAA... | \n39.201677 | \n\n | [-71.062507, 42.365968] | \n-71.062507 | \n42.365968 | \n1 | \n
| 4 | \n4 | \n0 | \nLRUugHAVLoA1AAAA7wEAAKAAAADqAAAAYZa9QBEBXEIOWo... | \n1.865658 | \n\n | [-71.061735, 42.369195] | \n-71.061735 | \n42.369195 | \n1 | \n
| ... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n
| 170 | \n49 | \n0 | \n7hAigPYQIoA2AgAAYwEAAAAAAAAAAAAAnsd7Qq9XHUIAAA... | \n7.478611 | \n\n | [-71.096959, 42.344689] | \n-71.096959 | \n42.344689 | \n3 | \n
| 171 | \n50 | \n0 | \nbwwigH0MIoAFAAAAEAAAAFUAAAArAAAAag0xP3921D-BFx... | \n8.340476 | \n\n | [-71.095003, 42.342001] | \n-71.095003 | \n42.342001 | \n3 | \n
| 172 | \n51 | \n0 | \nMQwigFwMIoAoAAAANQAAABwAAAB-AAAAoidqQSAYl0GvUh... | \n11.504463 | \n\n | [-71.094327, 42.341231] | \n-71.094327 | \n42.341231 | \n3 | \n
| 173 | \n52 | \n0 | \nk4chgBiIIYAKAAAAFwAAAPQDAAB_AgAAHn2aP-biHUBi6e... | \n36.240351 | \n\n | [-71.093834, 42.339096] | \n-71.093834 | \n42.339096 | \n3 | \n
| 174 | \n53 | \n0 | \nDoUhgBeFIYCcAAAAJgAAAAAAAAARAAAAm0CKQdkZiEAAAA... | \n0.236958 | \nNortheastern (Inbound) | \n[-71.090331, 42.339762] | \n-71.090331 | \n42.339762 | \n3 | \n
175 rows × 9 columns
\n| \n | waypoint_index | \ntrips_index | \nhint | \ndistance | \nname | \nlocation | \nlat | \nlon | \nroute | \n
|---|---|---|---|---|---|---|---|---|---|
| 0 | \n0 | \n0 | \n1IwsgDuNLIBFAAAAWgEAAA8AAAAAAAAAFQP1QGa9GUI7qN... | \n8.262982 | \n\n | [-71.053931, 42.365054] | \n-71.053931 | \n42.365054 | \n1 | \n
| 1 | \n1 | \n0 | \nLRUugHAVLoA1AAAA7wEAAKAAAADqAAAAYZa9QBEBXEIOWo... | \n1.865658 | \n\n | [-71.061735, 42.369195] | \n-71.061735 | \n42.369195 | \n1 | \n
| 2 | \n2 | \n0 | \nlM4AgM3LAIAEAAAAHAAAAJEAAAC_AgAAyLv6PxJ7NEGyPn... | \n2.242639 | \nMiller's River Littoral Way | \n[-71.065634, 42.371832] | \n-71.065634 | \n42.371832 | \n1 | \n
| 3 | \n3 | \n0 | \nZQ0fgPINH4AgAAAAEQAAAFEAAAAqAAAArYRYQRHu20BfWQ... | \n48.627645 | \n\n | [-71.06828, 42.369868] | \n-71.068280 | \n42.369868 | \n4 | \n
| 4 | \n4 | \n0 | \nHR8ugIJiBICVAQAARwAAAAAAAACLAAAAQ1M0Qu3l-EAAAA... | \n0.645763 | \n\n | [-71.094764, 42.377355] | \n-71.094764 | \n42.377355 | \n1 | \n
| ... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n
| 184 | \n11 | \n0 | \n-2EugABiLoCcAQAAigAAAAAAAAAAAAAAMQI3QqZ0dUEAAA... | \n7.363621 | \n\n | [-71.102659, 42.382131] | \n-71.102659 | \n42.382131 | \n10 | \n
| 185 | \n12 | \n0 | \nVSIfgAYjH4AUAAAAAAAAACUBAADDAAAAaIcPQAAAAADYBw... | \n18.888832 | \n\n | [-71.110851, 42.374259] | \n-71.110851 | \n42.374259 | \n6 | \n
| 186 | \n13 | \n0 | \n0OEhgPvhIYADAAAABgAAAA8AAAA0AAAA2lq-PipQFD-Y-N... | \n2.009578 | \n\n | [-71.085166, 42.349997] | \n-71.085166 | \n42.349997 | \n6 | \n
| 187 | \n14 | \n0 | \nC-AhgGbgIYBZAAAAMQAAAAAAAABqAAAAj5QfQS1zq0AAAA... | \n4.887502 | \n\n | [-71.091358, 42.348977] | \n-71.091358 | \n42.348977 | \n6 | \n
| 188 | \n15 | \n0 | \nDoUhgBeFIYCcAAAAJgAAAAAAAAARAAAAm0CKQdkZiEAAAA... | \n0.236958 | \nNortheastern (Inbound) | \n[-71.090331, 42.339762] | \n-71.090331 | \n42.339762 | \n6 | \n
189 rows × 9 columns
\n