Skip to content

Instantly share code, notes, and snippets.

@fndari
Created September 15, 2018 02:29
Show Gist options
  • Save fndari/dfa95ebdfca238760dfa39c2161d8ed9 to your computer and use it in GitHub Desktop.
Save fndari/dfa95ebdfca238760dfa39c2161d8ed9 to your computer and use it in GitHub Desktop.
Example using the OpenRouteService (ORS) API
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Distances\n",
"\n",
"The `trips` table shows the duration and endpoints of a GoBike trip. It would be interesting to know, for a given set of endpoints, what is the distance between them, and the time that it would take to cycle between them, i.e. a *direct* trip. Clearly not all GoBike trips will be direct: stopping along the way, running errands, or staying at a particular place without returning the bike to a station, etc; but it nonetheless can provide a useful basis for analyzing trip routes."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>name</th>\n",
" <th>latitude</th>\n",
" <th>longitude</th>\n",
" <th>is_bart</th>\n",
" </tr>\n",
" <tr>\n",
" <th>station_id</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Powell St BART Station (Market St at 4th St)</td>\n",
" <td>37.786375</td>\n",
" <td>-122.404904</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Cyril Magnin St at Ellis St</td>\n",
" <td>37.785881</td>\n",
" <td>-122.408915</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Powell St BART Station (Market St at 5th St)</td>\n",
" <td>37.783899</td>\n",
" <td>-122.408445</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>The Embarcadero at Sansome St</td>\n",
" <td>37.804770</td>\n",
" <td>-122.403234</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Frank H Ogawa Plaza</td>\n",
" <td>37.804562</td>\n",
" <td>-122.271738</td>\n",
" <td>False</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" name latitude \\\n",
"station_id \n",
"3 Powell St BART Station (Market St at 4th St) 37.786375 \n",
"4 Cyril Magnin St at Ellis St 37.785881 \n",
"5 Powell St BART Station (Market St at 5th St) 37.783899 \n",
"6 The Embarcadero at Sansome St 37.804770 \n",
"7 Frank H Ogawa Plaza 37.804562 \n",
"\n",
" longitude is_bart \n",
"station_id \n",
"3 -122.404904 True \n",
"4 -122.408915 False \n",
"5 -122.408445 True \n",
"6 -122.403234 False \n",
"7 -122.271738 False "
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"\n",
"\n",
"STATIONS = pd.read_pickle('stations.pkl')\n",
"STATIONS.head()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>name</th>\n",
" <th>latitude</th>\n",
" <th>longitude</th>\n",
" <th>is_bart</th>\n",
" </tr>\n",
" <tr>\n",
" <th>station_id</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>245</th>\n",
" <td>Downtown Berkeley BART</td>\n",
" <td>37.870348</td>\n",
" <td>-122.267764</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>246</th>\n",
" <td>Berkeley Civic Center</td>\n",
" <td>37.869060</td>\n",
" <td>-122.270556</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>250</th>\n",
" <td>North Berkeley BART Station</td>\n",
" <td>37.874014</td>\n",
" <td>-122.283019</td>\n",
" <td>True</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" name latitude longitude is_bart\n",
"station_id \n",
"245 Downtown Berkeley BART 37.870348 -122.267764 True\n",
"246 Berkeley Civic Center 37.869060 -122.270556 False\n",
"250 North Berkeley BART Station 37.874014 -122.283019 True"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"STATIONS[STATIONS.name.str.contains('Berkeley')]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Setting up the ORS environment\n",
"\n",
"The maximum request rate as indicated on the ORS website is, at least for the free tier, 40 req/min. There's also a daily limit of 2500 requests, but it won't be relevant for our purposes.\n",
"\n",
"We'll be using a cache to temporarily store our requests. This is especially useful when doing exploratory work, and benefits both the ORS servers (avoiding useless work), and us (the cached results will be available instantaneously).\n",
"\n",
"`requests-cache` offers a transparent drop-in mode, internally monkey-patching the top-level methods in `requests`. This is fine, but we can setup hooks using an explicit `Session` object, allowing us to implement a rate-limiting mechanism in addition."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"import time\n",
"import requests\n",
"import requests_cache\n",
"import openrouteservice as ors\n",
"\n",
"\n",
"ORS_API_KEY = '5b3ce3597851110001cf6248ef0005a62d4d4b1eaf229f96a4fc90e2'\n",
"ORS_URL_BASE = 'https://api.openrouteservice.org'\n",
"ORS_CLIENT = ors.Client(key=ORS_API_KEY) # Specify your personal API key\n",
"\n",
"requests_cache.install_cache('ors')\n",
"ORS_RATE_MAX = 30 / 60 # max is 40 req/min\n",
"ORS_RATE_TIMEOUT = 1 / ORS_RATE_MAX\n",
"ORS_SESSION = requests_cache.CachedSession()\n",
"\n",
"\n",
"\n",
"def make_throttle_hook(timeout=1):\n",
" \"\"\"\n",
" Returns a response hook function which sleeps for `timeout` seconds if\n",
" response is not coming from the cache.\n",
" \n",
" From https://requests-cache.readthedocs.io/en/latest/user_guide.html#usage\n",
" \"\"\"\n",
" def hook(response, *args, **kwargs):\n",
" if not getattr(response, 'from_cache', False):\n",
" print(f'{response} not found in cache. Timeout for {timeout:.3f} s.')\n",
" time.sleep(timeout)\n",
" return response\n",
" return hook\n",
"\n",
"ORS_SESSION.hooks = {'response': make_throttle_hook(ORS_RATE_TIMEOUT)}"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>name</th>\n",
" <th>latitude</th>\n",
" <th>longitude</th>\n",
" <th>is_bart</th>\n",
" </tr>\n",
" <tr>\n",
" <th>station_id</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Powell St BART Station (Market St at 4th St)</td>\n",
" <td>37.786375</td>\n",
" <td>-122.404904</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Cyril Magnin St at Ellis St</td>\n",
" <td>37.785881</td>\n",
" <td>-122.408915</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Powell St BART Station (Market St at 5th St)</td>\n",
" <td>37.783899</td>\n",
" <td>-122.408445</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>The Embarcadero at Sansome St</td>\n",
" <td>37.804770</td>\n",
" <td>-122.403234</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Frank H Ogawa Plaza</td>\n",
" <td>37.804562</td>\n",
" <td>-122.271738</td>\n",
" <td>False</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" name latitude \\\n",
"station_id \n",
"3 Powell St BART Station (Market St at 4th St) 37.786375 \n",
"4 Cyril Magnin St at Ellis St 37.785881 \n",
"5 Powell St BART Station (Market St at 5th St) 37.783899 \n",
"6 The Embarcadero at Sansome St 37.804770 \n",
"7 Frank H Ogawa Plaza 37.804562 \n",
"\n",
" longitude is_bart \n",
"station_id \n",
"3 -122.404904 True \n",
"4 -122.408915 False \n",
"5 -122.408445 True \n",
"6 -122.403234 False \n",
"7 -122.271738 False "
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"TEST = STATIONS.head()\n",
"TEST"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<Response [200]> not found in cache. Timeout for 2.000 s.\n"
]
},
{
"data": {
"text/plain": [
"{'county': 'Alameda County',\n",
" 'locality': 'Oakland',\n",
" 'neighbourhood': 'Downtown'}"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def get_geocode_reverse(coords):\n",
" url = ORS_URL_BASE + '/geocode/reverse'\n",
"\n",
" params = {\n",
" 'api_key': ORS_API_KEY,\n",
" 'point.lon': coords[0],\n",
" 'point.lat': coords[1],\n",
"# 'sources': 'oa,gn,osm', # we don't need this\n",
"# 'size': 1,\n",
" }\n",
" \n",
" return ORS_SESSION.get(url, params=params)\n",
"\n",
"from pprint import pprint\n",
"\n",
"def get_features(resp_data, fields=None):\n",
" res = {}\n",
" try:\n",
" props = resp_data['features'][0]['properties']\n",
" except (KeyError, IndexError):\n",
" print('could not extract the desired fields')\n",
" pprint(resp_data)\n",
" props = {}\n",
" else:\n",
" subset = fields or props.keys()\n",
" res = {key: props.get(key) for key in subset}\n",
" return res\n",
"\n",
"\n",
"test_coords = (-122.271738, 37.803562)\n",
"resp = get_geocode_reverse(test_coords)\n",
"get_features(resp.json(),\n",
" fields=['county', 'locality', 'neighbourhood']\n",
" )\n"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"import time\n",
"# from tqdm import tqdm_notebook # not yet working, I'll have to update/reinstall JupyterLab\n",
" # but for obvious reasons I don't really want to\n",
"\n",
"# TODO it would be great to have rate limiting and cache functionality connected,\n",
"# so that the rate limiting only applies to requests not found in the cache\n",
"\n",
"def timeout_if_not_from_cache(resp, timeout=1):\n",
" needs_timeout = getattr(resp, 'from_cache', False)\n",
" if needs_timeout:\n",
" time.sleep(timeout)\n",
"\n",
"def get_features_data(df, requests_per_minute=300, **kwargs):\n",
" data = []\n",
" timeout = 60 / requests_per_minute\n",
" coords = df[['longitude', 'latitude']]\n",
" for coord in coords.itertuples():\n",
"\n",
" resp = get_geocode_reverse(coord[1:])\n",
"\n",
" # TODO improvement: this could be improved with requests session hooks\n",
"# timeout_if_not_cached(resp, ORS_RATE_TIMEOUT)\n",
"\n",
" datum = get_features(resp.json(), **kwargs)\n",
" datum.update(station_id=coord.Index)\n",
" data.append(datum)\n",
" print(datum)\n",
" \n",
" return data\n",
"\n",
"def process_stations_info(df):\n",
" return (df\n",
" # this should be OK for most of the fields that we'll be considering\n",
" .astype('category')\n",
" # why can't we just agree on using the AmE spelling?\n",
" .rename(columns={'neighbourhood': 'neighborhood'})\n",
" )\n",
"\n",
"def enrich_stations_info(df):\n",
" data = get_features_data(df,\n",
" fields=['county', 'locality', 'neighbourhood']\n",
" )\n",
" return pd.concat([STATIONS,\n",
" (pd.DataFrame(data)\n",
" .set_index('station_id')\n",
" .pipe(process_stations_info)\n",
" )], axis=1)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 3}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Union Square', 'station_id': 4}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Union Square', 'station_id': 5}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'North Waterfront', 'station_id': 6}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Downtown', 'station_id': 7}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'North Waterfront', 'station_id': 8}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'North Waterfront', 'station_id': 9}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Chinatown', 'station_id': 10}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'North Waterfront', 'station_id': 11}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Financial District', 'station_id': 13}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Financial District', 'station_id': 14}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Financial District', 'station_id': 15}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Financial District', 'station_id': 16}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Financial District', 'station_id': 17}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Fairview Park', 'station_id': 18}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Union Square', 'station_id': 19}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Financial District', 'station_id': 20}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Financial District', 'station_id': 21}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 22}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Rincon Hill', 'station_id': 23}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Rincon Hill', 'station_id': 24}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 25}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Rincon Hill', 'station_id': 26}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Rincon Hill', 'station_id': 27}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Rincon Hill', 'station_id': 28}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Anza Vista', 'station_id': 29}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission Bay', 'station_id': 30}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Lower Pacific Heights', 'station_id': 31}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Tenderloin', 'station_id': 33}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Tenderloin', 'station_id': 34}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Sunol-Midtown', 'station_id': 35}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 36}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Rincon Hill', 'station_id': 37}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Western Addition', 'station_id': 39}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Western Addition', 'station_id': 40}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Civic Center', 'station_id': 41}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Civic Center', 'station_id': 42}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Civic Center', 'station_id': 43}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Tenderloin', 'station_id': 44}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 45}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Rancho San Antonio', 'station_id': 46}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 47}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Beach', 'station_id': 48}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Beach', 'station_id': 49}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Beach', 'station_id': 50}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Western Addition', 'station_id': 52}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Alamo Square', 'station_id': 53}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Hayes Valley', 'station_id': 55}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Lower Haight', 'station_id': 56}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 58}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 59}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 60}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 61}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 62}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 63}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 64}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission Bay', 'station_id': 66}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission Bay', 'station_id': 67}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'North Panhandle', 'station_id': 70}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'North Panhandle', 'station_id': 71}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Lower Haight', 'station_id': 72}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Hayes Valley', 'station_id': 74}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': None, 'station_id': 75}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 76}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 77}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 78}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 79}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 80}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission Bay', 'station_id': 81}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Duboce Triangle', 'station_id': 84}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Duboce Triangle', 'station_id': 85}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Duboce Triangle', 'station_id': 86}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 88}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Showplace Square', 'station_id': 89}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Showplace Square', 'station_id': 90}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission Bay', 'station_id': 93}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Duboce Triangle', 'station_id': 95}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission Dolores', 'station_id': 96}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 97}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 98}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 99}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 100}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Showplace Square', 'station_id': 101}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Showplace Square', 'station_id': 102}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'The Castro', 'station_id': 105}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'The Castro', 'station_id': 106}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission Dolores', 'station_id': 107}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 108}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission Dolores', 'station_id': 109}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 110}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 112}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 113}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Potrero Hill', 'station_id': 114}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Potrero Hill', 'station_id': 115}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Potrero Hill', 'station_id': 116}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'The Castro', 'station_id': 118}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'The Castro', 'station_id': 119}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission Dolores', 'station_id': 120}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission Dolores', 'station_id': 121}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 122}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 123}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 124}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 125}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Dogpatch', 'station_id': 126}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 127}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 129}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Potrero Hill', 'station_id': 130}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Dolores Heights', 'station_id': 131}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Dolores Heights', 'station_id': 132}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 133}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 134}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Noe Valley', 'station_id': 137}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Noe Valley', 'station_id': 138}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 139}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Dolores Heights', 'station_id': 140}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': None, 'station_id': 141}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Bernal Heights', 'station_id': 144}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Noe Valley', 'station_id': 145}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': None, 'station_id': 146}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': None, 'station_id': 147}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Emeryville', 'neighbourhood': None, 'station_id': 148}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Emeryville', 'neighbourhood': None, 'station_id': 149}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Longfellow', 'station_id': 150}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Emeryville', 'neighbourhood': 'Gaskill', 'station_id': 151}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Emeryville', 'neighbourhood': 'Gaskill', 'station_id': 152}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Emeryville', 'neighbourhood': 'Golden Gate', 'station_id': 153}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Emeryville', 'neighbourhood': 'Golden Gate', 'station_id': 154}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Emeryville', 'neighbourhood': 'Golden Gate', 'station_id': 156}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Emeryville', 'neighbourhood': 'Golden Gate', 'station_id': 157}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Temescal', 'station_id': 158}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Mcclymonds', 'station_id': 159}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'South Prescott', 'station_id': 160}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Chinatown', 'station_id': 162}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Chinatown', 'station_id': 163}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Hoover', 'station_id': 164}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Rockridge', 'station_id': 167}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Bushrod', 'station_id': 169}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Fairview Park', 'station_id': 170}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Rockridge', 'station_id': 172}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Bushrod', 'station_id': 173}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Temescal', 'station_id': 174}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Temescal', 'station_id': 175}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Mosswood', 'station_id': 176}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Mosswood', 'station_id': 177}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Harrison Street', 'station_id': 178}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Northgate', 'station_id': 179}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Northgate', 'station_id': 180}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Downtown', 'station_id': 181}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Downtown', 'station_id': 182}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Downtown', 'station_id': 183}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Downtown', 'station_id': 184}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Civic Center', 'station_id': 185}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Gold Coast', 'station_id': 186}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Bushrod', 'station_id': 188}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': None, 'station_id': 189}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Longfellow', 'station_id': 190}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Longfellow', 'station_id': 191}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Longfellow', 'station_id': 192}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Lakeshore', 'station_id': 193}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Trestle Glen', 'station_id': 194}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Adams Point', 'station_id': 195}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Adams Point', 'station_id': 196}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Cleveland Heights', 'station_id': 197}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Gold Coast', 'station_id': 198}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Downtown', 'station_id': 199}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Merritt', 'station_id': 200}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Laney', 'station_id': 201}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Old City', 'station_id': 202}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Shafter', 'station_id': 204}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Shafter', 'station_id': 205}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Rockridge', 'station_id': 206}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Mountain View Cemetary', 'station_id': 207}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'South Campus', 'station_id': 208}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Longfellow', 'station_id': 209}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Temescal', 'station_id': 210}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Piedmont Avenue', 'station_id': 211}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Mosswood', 'station_id': 212}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Clawson', 'station_id': 213}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Hoover', 'station_id': 214}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Pill Hill', 'station_id': 215}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Hoover', 'station_id': 216}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Oak Center', 'station_id': 218}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Oak Center', 'station_id': 219}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'San Pablo Gateway', 'station_id': 220}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'East Peralta', 'station_id': 221}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'East Peralta', 'station_id': 222}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Mission', 'station_id': 223}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Embarcadero', 'station_id': 224}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Hawthorne', 'station_id': 226}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Patten', 'station_id': 227}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': None, 'station_id': 228}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Jefferson', 'station_id': 229}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Prescott', 'station_id': 230}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Oak Center', 'station_id': 231}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Old City', 'station_id': 232}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Merritt', 'station_id': 233}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'St. Elizabeth', 'station_id': 234}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Acorn', 'station_id': 235}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Acorn', 'station_id': 236}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Fruitvale Station', 'station_id': 237}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Central', 'station_id': 238}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Telegraph Avenue', 'station_id': 239}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Telegraph Avenue', 'station_id': 240}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'South Berkeley', 'station_id': 241}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Telegraph Avenue', 'station_id': 243}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Gourmet Ghetto', 'station_id': 244}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Downtown', 'station_id': 245}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Downtown', 'station_id': 246}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Telegraph Avenue', 'station_id': 247}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'South Berkeley', 'station_id': 248}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Elmwood', 'station_id': 249}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Central', 'station_id': 250}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Central', 'station_id': 251}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'North', 'station_id': 254}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'North', 'station_id': 258}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'West Berkeley', 'station_id': 259}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Southwest Berkeley', 'station_id': 263}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Southwest Berkeley', 'station_id': 265}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Southside', 'station_id': 266}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Elmwood', 'station_id': 267}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Southside', 'station_id': 268}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Southside', 'station_id': 269}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'Southwest Berkeley', 'station_id': 270}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'South Berkeley', 'station_id': 274}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Hensley', 'station_id': 275}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Garden Alameda', 'station_id': 276}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Garden Alameda', 'station_id': 277}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Garden Alameda', 'station_id': 278}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'North Campus', 'station_id': 279}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'San Jose State University', 'station_id': 280}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'San Jose State University', 'station_id': 281}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Plaza de Cesar Chavez', 'station_id': 282}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Lakehouse', 'station_id': 283}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 284}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Japantown', 'station_id': 285}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'East Campus', 'station_id': 286}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Convention and Cultural District', 'station_id': 287}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Civic Center', 'station_id': 288}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Japantown', 'station_id': 289}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Vendome', 'station_id': 290}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Guadalupe River Park', 'station_id': 291}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Japantown', 'station_id': 292}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Little Italy', 'station_id': 293}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Market', 'station_id': 294}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'South Campus', 'station_id': 295}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Spartan', 'station_id': 296}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Washington', 'station_id': 297}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Spartan', 'station_id': 299}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Tamien', 'station_id': 300}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Washington', 'station_id': 301}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Japantown', 'station_id': 304}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Vendome', 'station_id': 305}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'St. James Park', 'station_id': 306}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Guadalupe River Park', 'station_id': 307}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'San Pedro Square', 'station_id': 308}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'North Campus', 'station_id': 309}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'San Jose State University', 'station_id': 310}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Paseo', 'station_id': 311}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Sunol-Midtown', 'station_id': 312}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Adobe', 'station_id': 313}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Almaden-Santa Clara', 'station_id': 314}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'SoFA', 'station_id': 316}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'South Campus', 'station_id': 317}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'Convention and Cultural District', 'station_id': 318}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'South Of Market', 'station_id': 321}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'North Beach', 'station_id': 323}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'San Francisco County', 'locality': 'San Francisco', 'neighbourhood': 'Union Square', 'station_id': 324}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Santa Clara County', 'locality': 'San Jose', 'neighbourhood': 'South Campus', 'station_id': 327}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Downtown', 'station_id': 337}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Downtown', 'station_id': 338}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Oakland', 'neighbourhood': 'Chinatown', 'station_id': 339}\n",
"<Response [200]> not found in cache. Timeout for 2.000 s.\n",
"{'county': 'Alameda County', 'locality': 'Berkeley', 'neighbourhood': 'South Berkeley', 'station_id': 340}\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>name</th>\n",
" <th>latitude</th>\n",
" <th>longitude</th>\n",
" <th>is_bart</th>\n",
" <th>county</th>\n",
" <th>locality</th>\n",
" <th>neighborhood</th>\n",
" </tr>\n",
" <tr>\n",
" <th>station_id</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Powell St BART Station (Market St at 4th St)</td>\n",
" <td>37.786375</td>\n",
" <td>-122.404904</td>\n",
" <td>True</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>South Of Market</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Cyril Magnin St at Ellis St</td>\n",
" <td>37.785881</td>\n",
" <td>-122.408915</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Union Square</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Powell St BART Station (Market St at 5th St)</td>\n",
" <td>37.783899</td>\n",
" <td>-122.408445</td>\n",
" <td>True</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Union Square</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>The Embarcadero at Sansome St</td>\n",
" <td>37.804770</td>\n",
" <td>-122.403234</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>North Waterfront</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Frank H Ogawa Plaza</td>\n",
" <td>37.804562</td>\n",
" <td>-122.271738</td>\n",
" <td>False</td>\n",
" <td>Alameda County</td>\n",
" <td>Oakland</td>\n",
" <td>Downtown</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>The Embarcadero at Vallejo St</td>\n",
" <td>37.799953</td>\n",
" <td>-122.398525</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>North Waterfront</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Broadway at Battery St</td>\n",
" <td>37.798572</td>\n",
" <td>-122.400869</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>North Waterfront</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>Washington St at Kearny St</td>\n",
" <td>37.795393</td>\n",
" <td>-122.404770</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Chinatown</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>Davis St at Jackson St</td>\n",
" <td>37.797280</td>\n",
" <td>-122.398436</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>North Waterfront</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>Commercial St at Montgomery St</td>\n",
" <td>37.794231</td>\n",
" <td>-122.402923</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Financial District</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>Clay St at Battery St</td>\n",
" <td>37.795001</td>\n",
" <td>-122.399970</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Financial District</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>San Francisco Ferry Building (Harry Bridges Pl...</td>\n",
" <td>37.795392</td>\n",
" <td>-122.394203</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Financial District</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>Steuart St at Market St</td>\n",
" <td>37.794130</td>\n",
" <td>-122.394430</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Financial District</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>Embarcadero BART Station (Beale St at Market St)</td>\n",
" <td>37.792251</td>\n",
" <td>-122.397086</td>\n",
" <td>True</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Financial District</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>Telegraph Ave at Alcatraz Ave</td>\n",
" <td>37.850222</td>\n",
" <td>-122.260172</td>\n",
" <td>False</td>\n",
" <td>Alameda County</td>\n",
" <td>Oakland</td>\n",
" <td>Fairview Park</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>Post St at Kearny St</td>\n",
" <td>37.788975</td>\n",
" <td>-122.403452</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Union Square</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>Mechanics Monument Plaza (Market St at Bush St)</td>\n",
" <td>37.791300</td>\n",
" <td>-122.399051</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Financial District</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>Montgomery St BART Station (Market St at 2nd St)</td>\n",
" <td>37.789625</td>\n",
" <td>-122.400811</td>\n",
" <td>True</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Financial District</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>Howard St at Beale St</td>\n",
" <td>37.789756</td>\n",
" <td>-122.394643</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>South Of Market</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>The Embarcadero at Steuart St</td>\n",
" <td>37.791464</td>\n",
" <td>-122.391034</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Rincon Hill</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>Spear St at Folsom St</td>\n",
" <td>37.789677</td>\n",
" <td>-122.390428</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Rincon Hill</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>Howard St at 2nd St</td>\n",
" <td>37.787522</td>\n",
" <td>-122.397405</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>South Of Market</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>1st St at Folsom St</td>\n",
" <td>37.787290</td>\n",
" <td>-122.394380</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Rincon Hill</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>Beale St at Harrison St</td>\n",
" <td>37.788059</td>\n",
" <td>-122.391865</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Rincon Hill</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>The Embarcadero at Bryant St</td>\n",
" <td>37.787168</td>\n",
" <td>-122.388098</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Rincon Hill</td>\n",
" </tr>\n",
" <tr>\n",
" <th>29</th>\n",
" <td>O'Farrell St at Divisadero St</td>\n",
" <td>37.782405</td>\n",
" <td>-122.439446</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Anza Vista</td>\n",
" </tr>\n",
" <tr>\n",
" <th>30</th>\n",
" <td>San Francisco Caltrain (Townsend St at 4th St)</td>\n",
" <td>37.776598</td>\n",
" <td>-122.395282</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Mission Bay</td>\n",
" </tr>\n",
" <tr>\n",
" <th>31</th>\n",
" <td>Raymond Kimbell Playground</td>\n",
" <td>37.783813</td>\n",
" <td>-122.434559</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Lower Pacific Heights</td>\n",
" </tr>\n",
" <tr>\n",
" <th>33</th>\n",
" <td>Golden Gate Ave at Hyde St</td>\n",
" <td>37.781650</td>\n",
" <td>-122.415408</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Tenderloin</td>\n",
" </tr>\n",
" <tr>\n",
" <th>34</th>\n",
" <td>Father Alfred E Boeddeker Park</td>\n",
" <td>37.783988</td>\n",
" <td>-122.412408</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Tenderloin</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>293</th>\n",
" <td>W St John St at Guadalupe River Trail</td>\n",
" <td>37.335388</td>\n",
" <td>-121.897921</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>Little Italy</td>\n",
" </tr>\n",
" <tr>\n",
" <th>294</th>\n",
" <td>Pierce Ave at Market St</td>\n",
" <td>37.327581</td>\n",
" <td>-121.884559</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>Market</td>\n",
" </tr>\n",
" <tr>\n",
" <th>295</th>\n",
" <td>William St at 10th St</td>\n",
" <td>37.332794</td>\n",
" <td>-121.875926</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>South Campus</td>\n",
" </tr>\n",
" <tr>\n",
" <th>296</th>\n",
" <td>5th St at Virginia St</td>\n",
" <td>37.325998</td>\n",
" <td>-121.877120</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>Spartan</td>\n",
" </tr>\n",
" <tr>\n",
" <th>297</th>\n",
" <td>Locust St at Grant St</td>\n",
" <td>37.322980</td>\n",
" <td>-121.887931</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>Washington</td>\n",
" </tr>\n",
" <tr>\n",
" <th>299</th>\n",
" <td>Bestor Art Park</td>\n",
" <td>37.323678</td>\n",
" <td>-121.874119</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>Spartan</td>\n",
" </tr>\n",
" <tr>\n",
" <th>300</th>\n",
" <td>Palm St at Willow St</td>\n",
" <td>37.317298</td>\n",
" <td>-121.884995</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>Tamien</td>\n",
" </tr>\n",
" <tr>\n",
" <th>301</th>\n",
" <td>Willow St at Vine St</td>\n",
" <td>37.318450</td>\n",
" <td>-121.883172</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>Washington</td>\n",
" </tr>\n",
" <tr>\n",
" <th>304</th>\n",
" <td>Jackson St at 5th St</td>\n",
" <td>37.348759</td>\n",
" <td>-121.894798</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>Japantown</td>\n",
" </tr>\n",
" <tr>\n",
" <th>305</th>\n",
" <td>Ryland Park</td>\n",
" <td>37.342725</td>\n",
" <td>-121.895617</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>Vendome</td>\n",
" </tr>\n",
" <tr>\n",
" <th>306</th>\n",
" <td>Saint James Park</td>\n",
" <td>37.339301</td>\n",
" <td>-121.889937</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>St. James Park</td>\n",
" </tr>\n",
" <tr>\n",
" <th>307</th>\n",
" <td>SAP Center</td>\n",
" <td>37.332692</td>\n",
" <td>-121.900084</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>Guadalupe River Park</td>\n",
" </tr>\n",
" <tr>\n",
" <th>308</th>\n",
" <td>San Pedro Square</td>\n",
" <td>37.336802</td>\n",
" <td>-121.894090</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>San Pedro Square</td>\n",
" </tr>\n",
" <tr>\n",
" <th>309</th>\n",
" <td>San Jose City Hall</td>\n",
" <td>37.337391</td>\n",
" <td>-121.886995</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>North Campus</td>\n",
" </tr>\n",
" <tr>\n",
" <th>310</th>\n",
" <td>San Fernando St at 4th St</td>\n",
" <td>37.335885</td>\n",
" <td>-121.885660</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>San Jose State University</td>\n",
" </tr>\n",
" <tr>\n",
" <th>311</th>\n",
" <td>Paseo De San Antonio at 2nd St</td>\n",
" <td>37.333798</td>\n",
" <td>-121.886943</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>Paseo</td>\n",
" </tr>\n",
" <tr>\n",
" <th>312</th>\n",
" <td>San Jose Diridon Station</td>\n",
" <td>37.329732</td>\n",
" <td>-121.901782</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>Sunol-Midtown</td>\n",
" </tr>\n",
" <tr>\n",
" <th>313</th>\n",
" <td>Almaden Blvd at San Fernando St</td>\n",
" <td>37.331415</td>\n",
" <td>-121.893200</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>Adobe</td>\n",
" </tr>\n",
" <tr>\n",
" <th>314</th>\n",
" <td>Santa Clara St at Almaden Blvd</td>\n",
" <td>37.333988</td>\n",
" <td>-121.894902</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>Almaden-Santa Clara</td>\n",
" </tr>\n",
" <tr>\n",
" <th>316</th>\n",
" <td>San Salvador St at 1st St</td>\n",
" <td>37.330165</td>\n",
" <td>-121.885831</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>SoFA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>317</th>\n",
" <td>San Salvador St at 9th St</td>\n",
" <td>37.333955</td>\n",
" <td>-121.877349</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>South Campus</td>\n",
" </tr>\n",
" <tr>\n",
" <th>318</th>\n",
" <td>San Carlos St at Market St</td>\n",
" <td>37.330698</td>\n",
" <td>-121.888979</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>Convention and Cultural District</td>\n",
" </tr>\n",
" <tr>\n",
" <th>321</th>\n",
" <td>5th at Folsom</td>\n",
" <td>37.780146</td>\n",
" <td>-122.403071</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>South Of Market</td>\n",
" </tr>\n",
" <tr>\n",
" <th>323</th>\n",
" <td>Broadway at Kearny</td>\n",
" <td>37.798014</td>\n",
" <td>-122.405950</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>North Beach</td>\n",
" </tr>\n",
" <tr>\n",
" <th>324</th>\n",
" <td>Union Square (Powell St at Post St)</td>\n",
" <td>37.788300</td>\n",
" <td>-122.408531</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Union Square</td>\n",
" </tr>\n",
" <tr>\n",
" <th>327</th>\n",
" <td>5th St at San Salvador St</td>\n",
" <td>37.332039</td>\n",
" <td>-121.881766</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>South Campus</td>\n",
" </tr>\n",
" <tr>\n",
" <th>337</th>\n",
" <td>Webster St at 19th St</td>\n",
" <td>37.806970</td>\n",
" <td>-122.266588</td>\n",
" <td>False</td>\n",
" <td>Alameda County</td>\n",
" <td>Oakland</td>\n",
" <td>Downtown</td>\n",
" </tr>\n",
" <tr>\n",
" <th>338</th>\n",
" <td>13th St at Franklin St</td>\n",
" <td>37.803189</td>\n",
" <td>-122.270579</td>\n",
" <td>False</td>\n",
" <td>Alameda County</td>\n",
" <td>Oakland</td>\n",
" <td>Downtown</td>\n",
" </tr>\n",
" <tr>\n",
" <th>339</th>\n",
" <td>Jackson St at 11th St</td>\n",
" <td>37.800002</td>\n",
" <td>-122.266438</td>\n",
" <td>False</td>\n",
" <td>Alameda County</td>\n",
" <td>Oakland</td>\n",
" <td>Chinatown</td>\n",
" </tr>\n",
" <tr>\n",
" <th>340</th>\n",
" <td>Harmon St at Adeline St</td>\n",
" <td>37.849735</td>\n",
" <td>-122.270582</td>\n",
" <td>False</td>\n",
" <td>Alameda County</td>\n",
" <td>Berkeley</td>\n",
" <td>South Berkeley</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>272 rows × 7 columns</p>\n",
"</div>"
],
"text/plain": [
" name latitude \\\n",
"station_id \n",
"3 Powell St BART Station (Market St at 4th St) 37.786375 \n",
"4 Cyril Magnin St at Ellis St 37.785881 \n",
"5 Powell St BART Station (Market St at 5th St) 37.783899 \n",
"6 The Embarcadero at Sansome St 37.804770 \n",
"7 Frank H Ogawa Plaza 37.804562 \n",
"8 The Embarcadero at Vallejo St 37.799953 \n",
"9 Broadway at Battery St 37.798572 \n",
"10 Washington St at Kearny St 37.795393 \n",
"11 Davis St at Jackson St 37.797280 \n",
"13 Commercial St at Montgomery St 37.794231 \n",
"14 Clay St at Battery St 37.795001 \n",
"15 San Francisco Ferry Building (Harry Bridges Pl... 37.795392 \n",
"16 Steuart St at Market St 37.794130 \n",
"17 Embarcadero BART Station (Beale St at Market St) 37.792251 \n",
"18 Telegraph Ave at Alcatraz Ave 37.850222 \n",
"19 Post St at Kearny St 37.788975 \n",
"20 Mechanics Monument Plaza (Market St at Bush St) 37.791300 \n",
"21 Montgomery St BART Station (Market St at 2nd St) 37.789625 \n",
"22 Howard St at Beale St 37.789756 \n",
"23 The Embarcadero at Steuart St 37.791464 \n",
"24 Spear St at Folsom St 37.789677 \n",
"25 Howard St at 2nd St 37.787522 \n",
"26 1st St at Folsom St 37.787290 \n",
"27 Beale St at Harrison St 37.788059 \n",
"28 The Embarcadero at Bryant St 37.787168 \n",
"29 O'Farrell St at Divisadero St 37.782405 \n",
"30 San Francisco Caltrain (Townsend St at 4th St) 37.776598 \n",
"31 Raymond Kimbell Playground 37.783813 \n",
"33 Golden Gate Ave at Hyde St 37.781650 \n",
"34 Father Alfred E Boeddeker Park 37.783988 \n",
"... ... ... \n",
"293 W St John St at Guadalupe River Trail 37.335388 \n",
"294 Pierce Ave at Market St 37.327581 \n",
"295 William St at 10th St 37.332794 \n",
"296 5th St at Virginia St 37.325998 \n",
"297 Locust St at Grant St 37.322980 \n",
"299 Bestor Art Park 37.323678 \n",
"300 Palm St at Willow St 37.317298 \n",
"301 Willow St at Vine St 37.318450 \n",
"304 Jackson St at 5th St 37.348759 \n",
"305 Ryland Park 37.342725 \n",
"306 Saint James Park 37.339301 \n",
"307 SAP Center 37.332692 \n",
"308 San Pedro Square 37.336802 \n",
"309 San Jose City Hall 37.337391 \n",
"310 San Fernando St at 4th St 37.335885 \n",
"311 Paseo De San Antonio at 2nd St 37.333798 \n",
"312 San Jose Diridon Station 37.329732 \n",
"313 Almaden Blvd at San Fernando St 37.331415 \n",
"314 Santa Clara St at Almaden Blvd 37.333988 \n",
"316 San Salvador St at 1st St 37.330165 \n",
"317 San Salvador St at 9th St 37.333955 \n",
"318 San Carlos St at Market St 37.330698 \n",
"321 5th at Folsom 37.780146 \n",
"323 Broadway at Kearny 37.798014 \n",
"324 Union Square (Powell St at Post St) 37.788300 \n",
"327 5th St at San Salvador St 37.332039 \n",
"337 Webster St at 19th St 37.806970 \n",
"338 13th St at Franklin St 37.803189 \n",
"339 Jackson St at 11th St 37.800002 \n",
"340 Harmon St at Adeline St 37.849735 \n",
"\n",
" longitude is_bart county locality \\\n",
"station_id \n",
"3 -122.404904 True San Francisco County San Francisco \n",
"4 -122.408915 False San Francisco County San Francisco \n",
"5 -122.408445 True San Francisco County San Francisco \n",
"6 -122.403234 False San Francisco County San Francisco \n",
"7 -122.271738 False Alameda County Oakland \n",
"8 -122.398525 False San Francisco County San Francisco \n",
"9 -122.400869 False San Francisco County San Francisco \n",
"10 -122.404770 False San Francisco County San Francisco \n",
"11 -122.398436 False San Francisco County San Francisco \n",
"13 -122.402923 False San Francisco County San Francisco \n",
"14 -122.399970 False San Francisco County San Francisco \n",
"15 -122.394203 False San Francisco County San Francisco \n",
"16 -122.394430 False San Francisco County San Francisco \n",
"17 -122.397086 True San Francisco County San Francisco \n",
"18 -122.260172 False Alameda County Oakland \n",
"19 -122.403452 False San Francisco County San Francisco \n",
"20 -122.399051 False San Francisco County San Francisco \n",
"21 -122.400811 True San Francisco County San Francisco \n",
"22 -122.394643 False San Francisco County San Francisco \n",
"23 -122.391034 False San Francisco County San Francisco \n",
"24 -122.390428 False San Francisco County San Francisco \n",
"25 -122.397405 False San Francisco County San Francisco \n",
"26 -122.394380 False San Francisco County San Francisco \n",
"27 -122.391865 False San Francisco County San Francisco \n",
"28 -122.388098 False San Francisco County San Francisco \n",
"29 -122.439446 False San Francisco County San Francisco \n",
"30 -122.395282 False San Francisco County San Francisco \n",
"31 -122.434559 False San Francisco County San Francisco \n",
"33 -122.415408 False San Francisco County San Francisco \n",
"34 -122.412408 False San Francisco County San Francisco \n",
"... ... ... ... ... \n",
"293 -121.897921 False Santa Clara County San Jose \n",
"294 -121.884559 False Santa Clara County San Jose \n",
"295 -121.875926 False Santa Clara County San Jose \n",
"296 -121.877120 False Santa Clara County San Jose \n",
"297 -121.887931 False Santa Clara County San Jose \n",
"299 -121.874119 False Santa Clara County San Jose \n",
"300 -121.884995 False Santa Clara County San Jose \n",
"301 -121.883172 False Santa Clara County San Jose \n",
"304 -121.894798 False Santa Clara County San Jose \n",
"305 -121.895617 False Santa Clara County San Jose \n",
"306 -121.889937 False Santa Clara County San Jose \n",
"307 -121.900084 False Santa Clara County San Jose \n",
"308 -121.894090 False Santa Clara County San Jose \n",
"309 -121.886995 False Santa Clara County San Jose \n",
"310 -121.885660 False Santa Clara County San Jose \n",
"311 -121.886943 False Santa Clara County San Jose \n",
"312 -121.901782 False Santa Clara County San Jose \n",
"313 -121.893200 False Santa Clara County San Jose \n",
"314 -121.894902 False Santa Clara County San Jose \n",
"316 -121.885831 False Santa Clara County San Jose \n",
"317 -121.877349 False Santa Clara County San Jose \n",
"318 -121.888979 False Santa Clara County San Jose \n",
"321 -122.403071 False San Francisco County San Francisco \n",
"323 -122.405950 False San Francisco County San Francisco \n",
"324 -122.408531 False San Francisco County San Francisco \n",
"327 -121.881766 False Santa Clara County San Jose \n",
"337 -122.266588 False Alameda County Oakland \n",
"338 -122.270579 False Alameda County Oakland \n",
"339 -122.266438 False Alameda County Oakland \n",
"340 -122.270582 False Alameda County Berkeley \n",
"\n",
" neighborhood \n",
"station_id \n",
"3 South Of Market \n",
"4 Union Square \n",
"5 Union Square \n",
"6 North Waterfront \n",
"7 Downtown \n",
"8 North Waterfront \n",
"9 North Waterfront \n",
"10 Chinatown \n",
"11 North Waterfront \n",
"13 Financial District \n",
"14 Financial District \n",
"15 Financial District \n",
"16 Financial District \n",
"17 Financial District \n",
"18 Fairview Park \n",
"19 Union Square \n",
"20 Financial District \n",
"21 Financial District \n",
"22 South Of Market \n",
"23 Rincon Hill \n",
"24 Rincon Hill \n",
"25 South Of Market \n",
"26 Rincon Hill \n",
"27 Rincon Hill \n",
"28 Rincon Hill \n",
"29 Anza Vista \n",
"30 Mission Bay \n",
"31 Lower Pacific Heights \n",
"33 Tenderloin \n",
"34 Tenderloin \n",
"... ... \n",
"293 Little Italy \n",
"294 Market \n",
"295 South Campus \n",
"296 Spartan \n",
"297 Washington \n",
"299 Spartan \n",
"300 Tamien \n",
"301 Washington \n",
"304 Japantown \n",
"305 Vendome \n",
"306 St. James Park \n",
"307 Guadalupe River Park \n",
"308 San Pedro Square \n",
"309 North Campus \n",
"310 San Jose State University \n",
"311 Paseo \n",
"312 Sunol-Midtown \n",
"313 Adobe \n",
"314 Almaden-Santa Clara \n",
"316 SoFA \n",
"317 South Campus \n",
"318 Convention and Cultural District \n",
"321 South Of Market \n",
"323 North Beach \n",
"324 Union Square \n",
"327 South Campus \n",
"337 Downtown \n",
"338 Downtown \n",
"339 Chinatown \n",
"340 South Berkeley \n",
"\n",
"[272 rows x 7 columns]"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"STATIONS_INFO = enrich_stations_info(STATIONS)\n",
"STATIONS_INFO"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"Important snippet: use `groupby().size()` instead of `groupby()[any_col_name].dropna().count()` or whatever complicated method I used to use to do this"
]
},
{
"cell_type": "code",
"execution_count": 80,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"county locality \n",
"San Francisco County San Francisco 122\n",
"Alameda County Oakland 76\n",
"Santa Clara County San Jose 41\n",
"Alameda County Berkeley 25\n",
" Emeryville 8\n",
"dtype: int64"
]
},
"execution_count": 80,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"STATIONS_INFO.groupby(['county', 'locality']).size().sort_values(ascending=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"STATIONS_INFO.groupby(['county', 'locality']).size().sort_values"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"STATIONS_INFO.groupby(['county', 'locality']).size().sort_values"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"county\n",
"San Francisco County 122\n",
"Alameda County 109\n",
"Santa Clara County 41\n",
"dtype: int64"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"STATIONS_INFO.groupby(['county']).size().sort_values(ascending=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"# Extending information about routes"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's build `ROUTES`, the $N \\times N$ station-to-station matrix, using a self-merge with prefixes.\n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>start_name</th>\n",
" <th>start_neighborhood</th>\n",
" <th>end_name</th>\n",
" <th>end_neighborhood</th>\n",
" </tr>\n",
" <tr>\n",
" <th>start_station_id</th>\n",
" <th>end_station_id</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th rowspan=\"5\" valign=\"top\">3</th>\n",
" <th>3</th>\n",
" <td>Powell St BART Station (Market St at 4th St)</td>\n",
" <td>South Of Market</td>\n",
" <td>Powell St BART Station (Market St at 4th St)</td>\n",
" <td>South Of Market</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Powell St BART Station (Market St at 4th St)</td>\n",
" <td>South Of Market</td>\n",
" <td>Cyril Magnin St at Ellis St</td>\n",
" <td>Union Square</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Powell St BART Station (Market St at 4th St)</td>\n",
" <td>South Of Market</td>\n",
" <td>Powell St BART Station (Market St at 5th St)</td>\n",
" <td>Union Square</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Powell St BART Station (Market St at 4th St)</td>\n",
" <td>South Of Market</td>\n",
" <td>The Embarcadero at Sansome St</td>\n",
" <td>North Waterfront</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Powell St BART Station (Market St at 4th St)</td>\n",
" <td>South Of Market</td>\n",
" <td>Frank H Ogawa Plaza</td>\n",
" <td>Downtown</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" start_name \\\n",
"start_station_id end_station_id \n",
"3 3 Powell St BART Station (Market St at 4th St) \n",
" 4 Powell St BART Station (Market St at 4th St) \n",
" 5 Powell St BART Station (Market St at 4th St) \n",
" 6 Powell St BART Station (Market St at 4th St) \n",
" 7 Powell St BART Station (Market St at 4th St) \n",
"\n",
" start_neighborhood \\\n",
"start_station_id end_station_id \n",
"3 3 South Of Market \n",
" 4 South Of Market \n",
" 5 South Of Market \n",
" 6 South Of Market \n",
" 7 South Of Market \n",
"\n",
" end_name \\\n",
"start_station_id end_station_id \n",
"3 3 Powell St BART Station (Market St at 4th St) \n",
" 4 Cyril Magnin St at Ellis St \n",
" 5 Powell St BART Station (Market St at 5th St) \n",
" 6 The Embarcadero at Sansome St \n",
" 7 Frank H Ogawa Plaza \n",
"\n",
" end_neighborhood \n",
"start_station_id end_station_id \n",
"3 3 South Of Market \n",
" 4 Union Square \n",
" 5 Union Square \n",
" 6 North Waterfront \n",
" 7 Downtown "
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def get_cartesian_merge(df, prefixes):\n",
" \n",
" def _pre_merge(df, prefix, temp_key, temp_val=0):\n",
" return (df\n",
" .reset_index()\n",
" .add_prefix(prefix)\n",
" .assign(**{temp_key: temp_val})\n",
" )\n",
"\n",
" temp_key = 'TEMP' # this is internal, so it's pointless to expose it\n",
" left, right = [df.pipe(_pre_merge, prefix, temp_key) for prefix in prefixes]\n",
" return (pd.merge(left, right, how='outer')\n",
" .drop(columns=temp_key)\n",
" )\n",
"\n",
"def create_endpoints(stations_df, fields=None, prefixes=None):\n",
" fields = fields or []\n",
" prefixes = prefixes or ['start_', 'end_']\n",
" return get_cartesian_merge(stations_df[fields], prefixes=prefixes)\n",
"\n",
"ROUTES = (create_endpoints(STATIONS_INFO, fields=['name', 'neighborhood'], prefixes=['start_', 'end_'])\n",
" .set_index(['start_station_id', 'end_station_id'])\n",
" )\n",
"ROUTES.head()"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"def get_coord_strings(df):\n",
" # the order is (LON, LAT)!!!\n",
" coords = df[['longitude', 'latitude']]\n",
" # huh, now `itertuples()` returns some kind of named tuple (which I guess makes sense, being a sort of immutable, simplified series)\n",
" return '|'.join([','.join(coord_tup[1:]) for coord_tup in coords.astype(str).itertuples()])\n",
"\n",
"def get_coords(df):\n",
" coords = df[['longitude', 'latitude']]\n",
" return [coord_tup[1:] for coord_tup in coords.itertuples()]\n",
"\n",
"def get_coords_str(df):\n",
" return '|'.join([','.join([str(_) for _ in coord_tup]) for coord_tup in get_coords(df)])"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'-122.40490436553955,37.78637526861584|-122.4089150084319,37.78588062694133|-122.40844488143921,37.78389935708493|-122.40323400000001,37.80477|-122.27173805236816,37.8045623549303'"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"get_coords_str(TEST)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[(-122.40490436553955, 37.78637526861584),\n",
" (-122.4089150084319, 37.78588062694133),\n",
" (-122.40844488143921, 37.78389935708493),\n",
" (-122.40323400000001, 37.80477),\n",
" (-122.27173805236816, 37.8045623549303)]"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"get_coords(TEST)"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"# locations = coords\n",
"def get_distance_matrix_client():\n",
" locations = get_coords(TEST)\n",
" return ORS_CLIENT.distance_matrix(locations,\n",
" profile='cycling-safe',\n",
"# resolve_locations=True,\n",
" metrics=['distance'],\n",
" optimized=False,\n",
"# dry_run=True\n",
" )\n",
"\n",
"# get_distance_matrix_client() # this doesn't work: 'Unable to find an appropriate routing profile.'"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Status code: 200\n"
]
},
{
"data": {
"text/plain": [
"{'distances': [[0, 614.72, 439.71, 2374.12, 13552],\n",
" [423.43, 0, 431.76, 2874.82, 13974.75],\n",
" [439.71, 288.29, 0, 2813.16, 13991.03],\n",
" [2647.1, 3403.52, 3086.13, 0, 13438.09],\n",
" [13532.97, 14147, 13972, 13493.97, 0]],\n",
" 'durations': [[0, 136.18, 108.73, 496.39, 7010.14],\n",
" [139.51, 0, 98.73, 602.28, 7149.51],\n",
" [95.04, 72.76, 0, 591.3, 7105.04],\n",
" [545.65, 710.32, 654.25, 0, 7023.38],\n",
" [7125.79, 7261.84, 7234.39, 7034.55, 0]],\n",
" 'destinations': [{'location': [-122.404992, 37.786444],\n",
" 'name': 'Market Street',\n",
" 'snapped_distance': 10.87},\n",
" {'location': [-122.40887, 37.785886],\n",
" 'name': 'Cyril Magnin Street',\n",
" 'snapped_distance': 4.04},\n",
" {'location': [-122.408387, 37.783856],\n",
" 'name': 'Hallidie Plaza',\n",
" 'snapped_distance': 7.02},\n",
" {'location': [-122.403161, 37.804833],\n",
" 'name': 'The Embarcadero',\n",
" 'snapped_distance': 9.47},\n",
" {'location': [-122.271752, 37.804541],\n",
" 'name': '14th Street',\n",
" 'snapped_distance': 2.7}],\n",
" 'sources': [{'location': [-122.404992, 37.786444],\n",
" 'name': 'Market Street',\n",
" 'snapped_distance': 10.87},\n",
" {'location': [-122.40887, 37.785886],\n",
" 'name': 'Cyril Magnin Street',\n",
" 'snapped_distance': 4.04},\n",
" {'location': [-122.408387, 37.783856],\n",
" 'name': 'Hallidie Plaza',\n",
" 'snapped_distance': 7.02},\n",
" {'location': [-122.403161, 37.804833],\n",
" 'name': 'The Embarcadero',\n",
" 'snapped_distance': 9.47},\n",
" {'location': [-122.271752, 37.804541],\n",
" 'name': '14th Street',\n",
" 'snapped_distance': 2.7}],\n",
" 'info': {'service': 'matrix',\n",
" 'engine': {'version': '4.5.0', 'build_date': '2018-06-20T16:38:42Z'},\n",
" 'attribution': 'openrouteservice.org | OpenStreetMap contributors',\n",
" 'timestamp': 1536628109466,\n",
" 'osm_file_md5_hash': 'aaab',\n",
" 'query': {'profile': 'cycling-safe', 'units': 'm'}}}"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def get_distance_matrix_request(df):\n",
" url = ORS_URL_BASE + '/matrix'\n",
" params = {\n",
" 'api_key': ORS_API_KEY,\n",
" 'profile': 'cycling-safe',\n",
" 'locations': get_coords_str(df),\n",
" 'metrics': 'distance|duration',\n",
" 'resolve_locations': True\n",
" }\n",
" resp = ORS_SESSION.get(url, params=params)\n",
" print(f'Status code: {resp.status_code}')\n",
" return resp\n",
"\n",
"# STATIONS_subset = STATIONS.loc[50:100] # to be able to submit in one request\n",
"\n",
"resp = get_distance_matrix_request(TEST)\n",
"resp.json()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"At this point, we set to obtain the full matrix for the whole set of stations. The ORS `matrix` API supports up to 50 locations at the time, so we divide our `STATIONS` table in chunks so that the size of each individual chunk doesn't exceed this limit.\n",
"\n",
"The `np.split()` function does not support unequal divisions if the number of chunks (as opposed to the size of the individual chunks) is specified, while the related `np.array_split()` does not support a maximum chunk size."
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[46, 46, 45, 45, 45, 45]"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[len(df) for df in np.array_split(STATIONS, 6)]"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[50, 50, 50, 50, 50, 22]"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def split_chunk_size(arr, chunk_size):\n",
" return (arr[i:i+chunk_size] for i in range(0, arr.shape[0], chunk_size))\n",
"\n",
"def split_chunks(arr, *, chunks=None, chunk_size_max=None):\n",
" if chunks is not None:\n",
" return np.array_split(arr, chunks)\n",
" elif chunk_size_max is not None:\n",
" return split_chunk_size(arr, chunk_size_max)\n",
"\n",
"[len(df) for df in split_chunk_size(STATIONS, 50)]"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[50, 50, 50, 50, 50, 22]"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[len(df) for df in split_chunks(STATIONS, chunk_size_max=50)]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"Intermezzo: how to un-zip a sequence"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lot = [(1, 2), (3, 4), (5, 6)]\n",
"list(zip(*lot))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [],
"source": [
"def create_df_from_matrix(matrix, reference_df):\n",
" idx_1d = reference_df.index\n",
" return pd.DataFrame(matrix,\n",
" # TODO check if this the start/end attribution is correct\n",
" index=idx_1d.rename('station_id_start'),\n",
" columns=idx_1d.rename('station_id_end'))\n",
"\n",
"def get_distance_matrix(resp_data, stations_df):\n",
" return create_df_from_matrix(resp_data['distances'], stations_df)\n",
"\n",
"def get_duration_matrix(resp_data, stations_df):\n",
" return (create_df_from_matrix(resp_data['durations'], stations_df)\n",
" .applymap(lambda _:pd.to_timedelta(_, unit='s'))\n",
" )\n",
"\n",
"def get_distance_duration(df):\n",
" resp = get_distance_matrix_request(df)\n",
" \n",
" dist = get_distance_matrix(resp.json(), df)\n",
" dur = get_duration_matrix(resp.json(), df)\n",
" \n",
" return dist, dur"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Status code: 200\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>station_id_end</th>\n",
" <th>3</th>\n",
" <th>4</th>\n",
" <th>5</th>\n",
" <th>6</th>\n",
" <th>7</th>\n",
" </tr>\n",
" <tr>\n",
" <th>station_id_start</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>0.00</td>\n",
" <td>614.72</td>\n",
" <td>439.71</td>\n",
" <td>2374.12</td>\n",
" <td>13552.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>423.43</td>\n",
" <td>0.00</td>\n",
" <td>431.76</td>\n",
" <td>2874.82</td>\n",
" <td>13974.75</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>439.71</td>\n",
" <td>288.29</td>\n",
" <td>0.00</td>\n",
" <td>2813.16</td>\n",
" <td>13991.03</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>2647.10</td>\n",
" <td>3403.52</td>\n",
" <td>3086.13</td>\n",
" <td>0.00</td>\n",
" <td>13438.09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>13532.97</td>\n",
" <td>14147.00</td>\n",
" <td>13972.00</td>\n",
" <td>13493.97</td>\n",
" <td>0.00</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
"station_id_end 3 4 5 6 7\n",
"station_id_start \n",
"3 0.00 614.72 439.71 2374.12 13552.00\n",
"4 423.43 0.00 431.76 2874.82 13974.75\n",
"5 439.71 288.29 0.00 2813.16 13991.03\n",
"6 2647.10 3403.52 3086.13 0.00 13438.09\n",
"7 13532.97 14147.00 13972.00 13493.97 0.00"
]
},
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"TEST_DIST, TEST_DUR = get_distance_duration(TEST)\n",
"TEST_DIST"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This matrix is not symmetric: this shows the (relative) variations between one direction and the other (i.e. switching `start` and `end` stations)"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {},
"outputs": [],
"source": [
"def get_matrix_relative_diff(df):\n",
" mean = (df + df.T) / 2\n",
" diff = (df - df.T)\n",
" # return 2 * (df - df.T) / (df + df.T)\n",
" return diff / mean"
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>station_id_end</th>\n",
" <th>3</th>\n",
" <th>4</th>\n",
" <th>5</th>\n",
" <th>6</th>\n",
" <th>7</th>\n",
" </tr>\n",
" <tr>\n",
" <th>station_id_start</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>NaN</td>\n",
" <td>0.368521</td>\n",
" <td>0.000000</td>\n",
" <td>-0.108731</td>\n",
" <td>0.001405</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>-0.368521</td>\n",
" <td>NaN</td>\n",
" <td>0.398500</td>\n",
" <td>-0.168420</td>\n",
" <td>-0.012250</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>0.000000</td>\n",
" <td>-0.398500</td>\n",
" <td>NaN</td>\n",
" <td>-0.092543</td>\n",
" <td>0.001361</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>0.108731</td>\n",
" <td>0.168420</td>\n",
" <td>0.092543</td>\n",
" <td>NaN</td>\n",
" <td>-0.004150</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>-0.001405</td>\n",
" <td>0.012250</td>\n",
" <td>-0.001361</td>\n",
" <td>0.004150</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
"station_id_end 3 4 5 6 7\n",
"station_id_start \n",
"3 NaN 0.368521 0.000000 -0.108731 0.001405\n",
"4 -0.368521 NaN 0.398500 -0.168420 -0.012250\n",
"5 0.000000 -0.398500 NaN -0.092543 0.001361\n",
"6 0.108731 0.168420 0.092543 NaN -0.004150\n",
"7 -0.001405 0.012250 -0.001361 0.004150 NaN"
]
},
"execution_count": 58,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"get_matrix_relative_diff(TEST_DIST)"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [],
"source": [
"def get_distance_duration_in_chunks(df_in, size_max=50):\n",
" \n",
" partial_results = []\n",
" for df_chunk in split_chunks(df_in, chunk_size_max=size_max):\n",
" print(f'chunk_size: {len(df_chunk)}')\n",
" partial_results.append(get_distance_duration(df_chunk))\n",
" \n",
" def matrix_to_column(df_matrix):\n",
" return df_matrix.stack()\n",
" \n",
" def assemble(list_of_tuples):\n",
" # list_of_tuples will have the form [(dist_0, dur_0), ... (dist_i, dur_i), (dist_n, dur_n)]\n",
" # separated has the form ((dist_0, ... dist_n), (dur_0, ... dur_n))\n",
" separated = zip(*list_of_tuples)\n",
" return [pd.concat((matrix_to_column(df) for df in partial_dfs), axis=0) for partial_dfs in separated]\n",
" \n",
" def to_df(matrix_columns):\n",
" columns = ['ors_distance', 'ors_duration']\n",
" return pd.DataFrame({name: data for name, data in zip(columns, matrix_columns)})\n",
"\n",
" return to_df(assemble(partial_results))"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"chunk_size: 50\n",
"Status code: 200\n",
"chunk_size: 50\n",
"Status code: 200\n",
"chunk_size: 50\n",
"Status code: 200\n",
"chunk_size: 50\n",
"Status code: 200\n",
"chunk_size: 50\n",
"Status code: 200\n",
"chunk_size: 22\n",
"Status code: 200\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>ors_distance</th>\n",
" <th>ors_duration</th>\n",
" </tr>\n",
" <tr>\n",
" <th>station_id_start</th>\n",
" <th>station_id_end</th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>61</th>\n",
" <th>70</th>\n",
" <td>3873.57</td>\n",
" <td>00:15:56.180000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>182</th>\n",
" <th>167</th>\n",
" <td>5121.14</td>\n",
" <td>00:20:16.110000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>30</th>\n",
" <th>17</th>\n",
" <td>2488.75</td>\n",
" <td>00:10:14.390000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>291</th>\n",
" <th>245</th>\n",
" <td>87203.03</td>\n",
" <td>05:13:01.640000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>154</th>\n",
" <th>156</th>\n",
" <td>476.16</td>\n",
" <td>00:01:40.180000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>36</th>\n",
" <th>10</th>\n",
" <td>1947.69</td>\n",
" <td>00:08:50.110000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>324</th>\n",
" <th>306</th>\n",
" <td>84087.27</td>\n",
" <td>05:40:41.940000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>119</th>\n",
" <th>78</th>\n",
" <td>2976.34</td>\n",
" <td>00:10:21.470000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>118</th>\n",
" <th>78</th>\n",
" <td>3191.17</td>\n",
" <td>00:12:08.750000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>180</th>\n",
" <th>151</th>\n",
" <td>4242.03</td>\n",
" <td>00:14:12.900000</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" ors_distance ors_duration\n",
"station_id_start station_id_end \n",
"61 70 3873.57 00:15:56.180000\n",
"182 167 5121.14 00:20:16.110000\n",
"30 17 2488.75 00:10:14.390000\n",
"291 245 87203.03 05:13:01.640000\n",
"154 156 476.16 00:01:40.180000\n",
"36 10 1947.69 00:08:50.110000\n",
"324 306 84087.27 05:40:41.940000\n",
"119 78 2976.34 00:10:21.470000\n",
"118 78 3191.17 00:12:08.750000\n",
"180 151 4242.03 00:14:12.900000"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ROUTES_ORS_INFO = get_distance_duration_in_chunks(STATIONS)\n",
"ROUTES_ORS_INFO.sample(10)"
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>name</th>\n",
" <th>latitude</th>\n",
" <th>longitude</th>\n",
" <th>is_bart</th>\n",
" <th>county</th>\n",
" <th>locality</th>\n",
" <th>neighborhood</th>\n",
" </tr>\n",
" <tr>\n",
" <th>station_id</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>324</th>\n",
" <td>Union Square (Powell St at Post St)</td>\n",
" <td>37.788300</td>\n",
" <td>-122.408531</td>\n",
" <td>False</td>\n",
" <td>San Francisco County</td>\n",
" <td>San Francisco</td>\n",
" <td>Union Square</td>\n",
" </tr>\n",
" <tr>\n",
" <th>306</th>\n",
" <td>Saint James Park</td>\n",
" <td>37.339301</td>\n",
" <td>-121.889937</td>\n",
" <td>False</td>\n",
" <td>Santa Clara County</td>\n",
" <td>San Jose</td>\n",
" <td>St. James Park</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" name latitude longitude \\\n",
"station_id \n",
"324 Union Square (Powell St at Post St) 37.788300 -122.408531 \n",
"306 Saint James Park 37.339301 -121.889937 \n",
"\n",
" is_bart county locality neighborhood \n",
"station_id \n",
"324 False San Francisco County San Francisco Union Square \n",
"306 False Santa Clara County San Jose St. James Park "
]
},
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"STATIONS_INFO.loc[(324, 306),:]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can calculate additional properties for the ORS-calculated routing info:"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {},
"outputs": [],
"source": [
"def get_mean_speed(distance, duration):\n",
" dist_km = (distance / 1000.)\n",
" dur_h = duration / pd.Timedelta(hours=1)\n",
" return (dist_km / dur_h).astype(float)\n",
"\n",
"def get_relative_diff(dist):\n",
" return (dist\n",
" .unstack()\n",
" # we're stacking/unstacking twice, but it's simpler to build the df from chunks in this way\n",
" .pipe(get_matrix_relative_diff)\n",
" .stack())"
]
},
{
"cell_type": "code",
"execution_count": 68,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>ors_distance</th>\n",
" <th>ors_duration</th>\n",
" <th>ors_distance_rel_diff</th>\n",
" <th>ors_mean_speed</th>\n",
" </tr>\n",
" <tr>\n",
" <th>station_id_start</th>\n",
" <th>station_id_end</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th rowspan=\"30\" valign=\"top\">3</th>\n",
" <th>3</th>\n",
" <td>0.00</td>\n",
" <td>00:00:00</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>614.72</td>\n",
" <td>00:02:16.180000</td>\n",
" <td>0.368521</td>\n",
" <td>16.250492</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>439.71</td>\n",
" <td>00:01:48.730000</td>\n",
" <td>0.000000</td>\n",
" <td>14.558595</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>2374.12</td>\n",
" <td>00:08:16.390000</td>\n",
" <td>-0.108731</td>\n",
" <td>17.217978</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>13552.00</td>\n",
" <td>01:56:50.140000</td>\n",
" <td>0.001405</td>\n",
" <td>6.959519</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>2207.17</td>\n",
" <td>00:07:23.360000</td>\n",
" <td>0.115297</td>\n",
" <td>17.921806</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>1698.04</td>\n",
" <td>00:06:16.710000</td>\n",
" <td>0.072657</td>\n",
" <td>16.227188</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>1541.17</td>\n",
" <td>00:06:05.030000</td>\n",
" <td>-0.116027</td>\n",
" <td>15.199332</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>1705.86</td>\n",
" <td>00:05:48.810000</td>\n",
" <td>0.034273</td>\n",
" <td>17.605848</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>1256.49</td>\n",
" <td>00:06:23.670000</td>\n",
" <td>0.232986</td>\n",
" <td>11.789726</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>1308.88</td>\n",
" <td>00:04:24.710000</td>\n",
" <td>-0.100478</td>\n",
" <td>17.800491</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>1403.06</td>\n",
" <td>00:06:22.850000</td>\n",
" <td>0.000000</td>\n",
" <td>13.193198</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>1313.43</td>\n",
" <td>00:04:53.240000</td>\n",
" <td>0.000000</td>\n",
" <td>16.124499</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>978.21</td>\n",
" <td>00:03:18.410000</td>\n",
" <td>-0.286960</td>\n",
" <td>17.748884</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>19729.66</td>\n",
" <td>02:18:47.860000</td>\n",
" <td>0.009394</td>\n",
" <td>8.528815</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>353.01</td>\n",
" <td>00:01:18.050000</td>\n",
" <td>-0.402091</td>\n",
" <td>16.282332</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>748.15</td>\n",
" <td>00:02:35.660000</td>\n",
" <td>0.000000</td>\n",
" <td>17.302711</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>534.25</td>\n",
" <td>00:02:38.680000</td>\n",
" <td>0.000000</td>\n",
" <td>12.120620</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>1371.21</td>\n",
" <td>00:04:56.930000</td>\n",
" <td>0.054540</td>\n",
" <td>16.624646</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>1828.79</td>\n",
" <td>00:06:48.280000</td>\n",
" <td>0.042257</td>\n",
" <td>16.125316</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>1811.14</td>\n",
" <td>00:06:52.990000</td>\n",
" <td>-0.131193</td>\n",
" <td>15.787559</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>1106.71</td>\n",
" <td>00:04:02.280000</td>\n",
" <td>0.150570</td>\n",
" <td>16.444428</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>1317.08</td>\n",
" <td>00:05:06.990000</td>\n",
" <td>-0.237283</td>\n",
" <td>15.445089</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>1631.11</td>\n",
" <td>00:06:33.990000</td>\n",
" <td>-0.125592</td>\n",
" <td>14.903921</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>2092.91</td>\n",
" <td>00:08:00.040000</td>\n",
" <td>0.000067</td>\n",
" <td>15.695517</td>\n",
" </tr>\n",
" <tr>\n",
" <th>29</th>\n",
" <td>3743.19</td>\n",
" <td>00:13:55.270000</td>\n",
" <td>0.102623</td>\n",
" <td>16.133088</td>\n",
" </tr>\n",
" <tr>\n",
" <th>30</th>\n",
" <td>1956.59</td>\n",
" <td>00:08:25.150000</td>\n",
" <td>0.000000</td>\n",
" <td>13.943827</td>\n",
" </tr>\n",
" <tr>\n",
" <th>31</th>\n",
" <td>3372.47</td>\n",
" <td>00:12:15.680000</td>\n",
" <td>0.114531</td>\n",
" <td>16.502952</td>\n",
" </tr>\n",
" <tr>\n",
" <th>33</th>\n",
" <td>1566.79</td>\n",
" <td>00:05:53.520000</td>\n",
" <td>0.335216</td>\n",
" <td>15.955092</td>\n",
" </tr>\n",
" <tr>\n",
" <th>34</th>\n",
" <td>1271.38</td>\n",
" <td>00:04:42.720000</td>\n",
" <td>0.462328</td>\n",
" <td>16.189049</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"8\" valign=\"top\">339</th>\n",
" <th>321</th>\n",
" <td>14005.37</td>\n",
" <td>02:01:27.250000</td>\n",
" <td>-0.029507</td>\n",
" <td>6.918842</td>\n",
" </tr>\n",
" <tr>\n",
" <th>323</th>\n",
" <td>13666.97</td>\n",
" <td>01:57:43.630000</td>\n",
" <td>-0.007983</td>\n",
" <td>6.965412</td>\n",
" </tr>\n",
" <tr>\n",
" <th>324</th>\n",
" <td>14865.15</td>\n",
" <td>02:01:17.540000</td>\n",
" <td>0.054850</td>\n",
" <td>7.353383</td>\n",
" </tr>\n",
" <tr>\n",
" <th>327</th>\n",
" <td>78961.26</td>\n",
" <td>04:45:58.940000</td>\n",
" <td>-0.032868</td>\n",
" <td>16.566323</td>\n",
" </tr>\n",
" <tr>\n",
" <th>337</th>\n",
" <td>1458.33</td>\n",
" <td>00:05:12.820000</td>\n",
" <td>0.336786</td>\n",
" <td>16.782776</td>\n",
" </tr>\n",
" <tr>\n",
" <th>338</th>\n",
" <td>1260.32</td>\n",
" <td>00:05:06.500000</td>\n",
" <td>0.649220</td>\n",
" <td>14.803106</td>\n",
" </tr>\n",
" <tr>\n",
" <th>339</th>\n",
" <td>0.00</td>\n",
" <td>00:00:00</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>340</th>\n",
" <td>6771.16</td>\n",
" <td>00:23:59.320000</td>\n",
" <td>-0.002222</td>\n",
" <td>16.935898</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"22\" valign=\"top\">340</th>\n",
" <th>304</th>\n",
" <td>82228.30</td>\n",
" <td>04:57:50.580000</td>\n",
" <td>-0.003945</td>\n",
" <td>16.564761</td>\n",
" </tr>\n",
" <tr>\n",
" <th>305</th>\n",
" <td>85098.10</td>\n",
" <td>05:04:59.850000</td>\n",
" <td>0.001309</td>\n",
" <td>16.740747</td>\n",
" </tr>\n",
" <tr>\n",
" <th>306</th>\n",
" <td>83697.23</td>\n",
" <td>05:03:00.390000</td>\n",
" <td>-0.026032</td>\n",
" <td>16.573353</td>\n",
" </tr>\n",
" <tr>\n",
" <th>307</th>\n",
" <td>85630.39</td>\n",
" <td>05:07:49.740000</td>\n",
" <td>0.002910</td>\n",
" <td>16.690511</td>\n",
" </tr>\n",
" <tr>\n",
" <th>308</th>\n",
" <td>85889.59</td>\n",
" <td>05:10:08.820000</td>\n",
" <td>0.005134</td>\n",
" <td>16.615912</td>\n",
" </tr>\n",
" <tr>\n",
" <th>309</th>\n",
" <td>83753.41</td>\n",
" <td>05:03:07.670000</td>\n",
" <td>-0.003548</td>\n",
" <td>16.577840</td>\n",
" </tr>\n",
" <tr>\n",
" <th>310</th>\n",
" <td>83979.91</td>\n",
" <td>05:03:42.970000</td>\n",
" <td>-0.029082</td>\n",
" <td>16.590472</td>\n",
" </tr>\n",
" <tr>\n",
" <th>311</th>\n",
" <td>84384.49</td>\n",
" <td>05:05:00.070000</td>\n",
" <td>-0.025117</td>\n",
" <td>16.600164</td>\n",
" </tr>\n",
" <tr>\n",
" <th>312</th>\n",
" <td>86063.74</td>\n",
" <td>05:09:09.210000</td>\n",
" <td>0.002891</td>\n",
" <td>16.703108</td>\n",
" </tr>\n",
" <tr>\n",
" <th>313</th>\n",
" <td>86151.07</td>\n",
" <td>05:08:19.250000</td>\n",
" <td>0.002279</td>\n",
" <td>16.765212</td>\n",
" </tr>\n",
" <tr>\n",
" <th>314</th>\n",
" <td>85772.32</td>\n",
" <td>05:07:06.870000</td>\n",
" <td>0.003020</td>\n",
" <td>16.757070</td>\n",
" </tr>\n",
" <tr>\n",
" <th>316</th>\n",
" <td>86971.57</td>\n",
" <td>05:10:56.350000</td>\n",
" <td>0.003479</td>\n",
" <td>16.782364</td>\n",
" </tr>\n",
" <tr>\n",
" <th>317</th>\n",
" <td>84416.07</td>\n",
" <td>05:04:38.340000</td>\n",
" <td>0.020165</td>\n",
" <td>16.626119</td>\n",
" </tr>\n",
" <tr>\n",
" <th>318</th>\n",
" <td>86687.24</td>\n",
" <td>05:10:01.050000</td>\n",
" <td>0.004193</td>\n",
" <td>16.777228</td>\n",
" </tr>\n",
" <tr>\n",
" <th>321</th>\n",
" <td>19330.98</td>\n",
" <td>02:20:57.120000</td>\n",
" <td>-0.018798</td>\n",
" <td>8.228750</td>\n",
" </tr>\n",
" <tr>\n",
" <th>323</th>\n",
" <td>18992.58</td>\n",
" <td>02:17:13.510000</td>\n",
" <td>-0.002993</td>\n",
" <td>8.304270</td>\n",
" </tr>\n",
" <tr>\n",
" <th>324</th>\n",
" <td>20190.76</td>\n",
" <td>02:20:47.410000</td>\n",
" <td>0.042807</td>\n",
" <td>8.604618</td>\n",
" </tr>\n",
" <tr>\n",
" <th>327</th>\n",
" <td>84848.62</td>\n",
" <td>05:06:26.710000</td>\n",
" <td>-0.025913</td>\n",
" <td>16.612816</td>\n",
" </tr>\n",
" <tr>\n",
" <th>337</th>\n",
" <td>6017.92</td>\n",
" <td>00:21:43.260000</td>\n",
" <td>0.042682</td>\n",
" <td>16.623323</td>\n",
" </tr>\n",
" <tr>\n",
" <th>338</th>\n",
" <td>6148.75</td>\n",
" <td>00:22:26.760000</td>\n",
" <td>-0.003191</td>\n",
" <td>16.436113</td>\n",
" </tr>\n",
" <tr>\n",
" <th>339</th>\n",
" <td>6786.22</td>\n",
" <td>00:24:15.630000</td>\n",
" <td>0.002222</td>\n",
" <td>16.783380</td>\n",
" </tr>\n",
" <tr>\n",
" <th>340</th>\n",
" <td>0.00</td>\n",
" <td>00:00:00</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>12984 rows × 4 columns</p>\n",
"</div>"
],
"text/plain": [
" ors_distance ors_duration \\\n",
"station_id_start station_id_end \n",
"3 3 0.00 00:00:00 \n",
" 4 614.72 00:02:16.180000 \n",
" 5 439.71 00:01:48.730000 \n",
" 6 2374.12 00:08:16.390000 \n",
" 7 13552.00 01:56:50.140000 \n",
" 8 2207.17 00:07:23.360000 \n",
" 9 1698.04 00:06:16.710000 \n",
" 10 1541.17 00:06:05.030000 \n",
" 11 1705.86 00:05:48.810000 \n",
" 13 1256.49 00:06:23.670000 \n",
" 14 1308.88 00:04:24.710000 \n",
" 15 1403.06 00:06:22.850000 \n",
" 16 1313.43 00:04:53.240000 \n",
" 17 978.21 00:03:18.410000 \n",
" 18 19729.66 02:18:47.860000 \n",
" 19 353.01 00:01:18.050000 \n",
" 20 748.15 00:02:35.660000 \n",
" 21 534.25 00:02:38.680000 \n",
" 22 1371.21 00:04:56.930000 \n",
" 23 1828.79 00:06:48.280000 \n",
" 24 1811.14 00:06:52.990000 \n",
" 25 1106.71 00:04:02.280000 \n",
" 26 1317.08 00:05:06.990000 \n",
" 27 1631.11 00:06:33.990000 \n",
" 28 2092.91 00:08:00.040000 \n",
" 29 3743.19 00:13:55.270000 \n",
" 30 1956.59 00:08:25.150000 \n",
" 31 3372.47 00:12:15.680000 \n",
" 33 1566.79 00:05:53.520000 \n",
" 34 1271.38 00:04:42.720000 \n",
"... ... ... \n",
"339 321 14005.37 02:01:27.250000 \n",
" 323 13666.97 01:57:43.630000 \n",
" 324 14865.15 02:01:17.540000 \n",
" 327 78961.26 04:45:58.940000 \n",
" 337 1458.33 00:05:12.820000 \n",
" 338 1260.32 00:05:06.500000 \n",
" 339 0.00 00:00:00 \n",
" 340 6771.16 00:23:59.320000 \n",
"340 304 82228.30 04:57:50.580000 \n",
" 305 85098.10 05:04:59.850000 \n",
" 306 83697.23 05:03:00.390000 \n",
" 307 85630.39 05:07:49.740000 \n",
" 308 85889.59 05:10:08.820000 \n",
" 309 83753.41 05:03:07.670000 \n",
" 310 83979.91 05:03:42.970000 \n",
" 311 84384.49 05:05:00.070000 \n",
" 312 86063.74 05:09:09.210000 \n",
" 313 86151.07 05:08:19.250000 \n",
" 314 85772.32 05:07:06.870000 \n",
" 316 86971.57 05:10:56.350000 \n",
" 317 84416.07 05:04:38.340000 \n",
" 318 86687.24 05:10:01.050000 \n",
" 321 19330.98 02:20:57.120000 \n",
" 323 18992.58 02:17:13.510000 \n",
" 324 20190.76 02:20:47.410000 \n",
" 327 84848.62 05:06:26.710000 \n",
" 337 6017.92 00:21:43.260000 \n",
" 338 6148.75 00:22:26.760000 \n",
" 339 6786.22 00:24:15.630000 \n",
" 340 0.00 00:00:00 \n",
"\n",
" ors_distance_rel_diff ors_mean_speed \n",
"station_id_start station_id_end \n",
"3 3 NaN NaN \n",
" 4 0.368521 16.250492 \n",
" 5 0.000000 14.558595 \n",
" 6 -0.108731 17.217978 \n",
" 7 0.001405 6.959519 \n",
" 8 0.115297 17.921806 \n",
" 9 0.072657 16.227188 \n",
" 10 -0.116027 15.199332 \n",
" 11 0.034273 17.605848 \n",
" 13 0.232986 11.789726 \n",
" 14 -0.100478 17.800491 \n",
" 15 0.000000 13.193198 \n",
" 16 0.000000 16.124499 \n",
" 17 -0.286960 17.748884 \n",
" 18 0.009394 8.528815 \n",
" 19 -0.402091 16.282332 \n",
" 20 0.000000 17.302711 \n",
" 21 0.000000 12.120620 \n",
" 22 0.054540 16.624646 \n",
" 23 0.042257 16.125316 \n",
" 24 -0.131193 15.787559 \n",
" 25 0.150570 16.444428 \n",
" 26 -0.237283 15.445089 \n",
" 27 -0.125592 14.903921 \n",
" 28 0.000067 15.695517 \n",
" 29 0.102623 16.133088 \n",
" 30 0.000000 13.943827 \n",
" 31 0.114531 16.502952 \n",
" 33 0.335216 15.955092 \n",
" 34 0.462328 16.189049 \n",
"... ... ... \n",
"339 321 -0.029507 6.918842 \n",
" 323 -0.007983 6.965412 \n",
" 324 0.054850 7.353383 \n",
" 327 -0.032868 16.566323 \n",
" 337 0.336786 16.782776 \n",
" 338 0.649220 14.803106 \n",
" 339 NaN NaN \n",
" 340 -0.002222 16.935898 \n",
"340 304 -0.003945 16.564761 \n",
" 305 0.001309 16.740747 \n",
" 306 -0.026032 16.573353 \n",
" 307 0.002910 16.690511 \n",
" 308 0.005134 16.615912 \n",
" 309 -0.003548 16.577840 \n",
" 310 -0.029082 16.590472 \n",
" 311 -0.025117 16.600164 \n",
" 312 0.002891 16.703108 \n",
" 313 0.002279 16.765212 \n",
" 314 0.003020 16.757070 \n",
" 316 0.003479 16.782364 \n",
" 317 0.020165 16.626119 \n",
" 318 0.004193 16.777228 \n",
" 321 -0.018798 8.228750 \n",
" 323 -0.002993 8.304270 \n",
" 324 0.042807 8.604618 \n",
" 327 -0.025913 16.612816 \n",
" 337 0.042682 16.623323 \n",
" 338 -0.003191 16.436113 \n",
" 339 0.002222 16.783380 \n",
" 340 NaN NaN \n",
"\n",
"[12984 rows x 4 columns]"
]
},
"execution_count": 68,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ROUTES_ORS_INFO.assign(\n",
" ors_distance_rel_diff=lambda d: get_relative_diff(d.ors_distance),\n",
" ors_mean_speed=lambda d: get_mean_speed(d.ors_distance, d.ors_duration),\n",
")\n",
"# .plot.hist('ors_mean_speed')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "gobikes",
"language": "python",
"name": "gobikes"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment