Skip to content

Instantly share code, notes, and snippets.

@egy1st
Created January 15, 2019 00:03
Show Gist options
  • Save egy1st/067de7216ec0343bc7055f5186257e2f to your computer and use it in GitHub Desktop.
Save egy1st/067de7216ec0343bc7055f5186257e2f to your computer and use it in GitHub Desktop.
Created on Cognitive Class Labs
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Tornoto Neighborhood Scrape"
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {},
"outputs": [],
"source": [
"# html_doc = \"https://en.wikipedia.org/wiki/List_of_postal_codes_of_Canada:_M\"\n"
]
},
{
"cell_type": "code",
"execution_count": 67,
"metadata": {},
"outputs": [],
"source": [
"# import pandas library to work with dataframe\n",
"import pandas as pd\n"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: BeautifulSoup4 in /home/jupyterlab/conda/lib/python3.6/site-packages (4.6.3)\n",
"Requirement already satisfied: lxml in /home/jupyterlab/conda/lib/python3.6/site-packages (4.2.5)\n",
"Requirement already satisfied: html5lib in /home/jupyterlab/conda/lib/python3.6/site-packages (0.9999999)\n"
]
}
],
"source": [
"# installing beautifulsoup4 package for scraping wikipedia page\n",
"# also install proper needed parsers to work with beautifulsoup4\n",
"\n",
"!pip install BeautifulSoup4\n",
"!pip install lxml\n",
"!pip install html5lib"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"import bs4\n",
"import requests # library to handle requests\n",
"import json # library to handle JSON files\n",
"from bs4 import BeautifulSoup"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"# URL on wikipedia to scrap, thus we can extract postal codes, Borough and Neighbrhood \n",
"url = \"https://en.wikipedia.org/wiki/List_of_postal_codes_of_Canada:_M\"\n",
"html_doc = requests.get(url).text"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"soup = BeautifulSoup(html_doc, 'html.parser')"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Our dataframe now is 212 rows\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>PostalCode</th>\n",
" <th>Borough</th>\n",
" <th>Neighborhood</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>M3A</td>\n",
" <td>North York</td>\n",
" <td>, Parkwoods</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>M4A</td>\n",
" <td>North York</td>\n",
" <td>, Parkwoods, Victoria Village</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>M5A</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>, Parkwoods, Victoria Village, Harbourfront</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>M5A</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Regent Park</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>M6A</td>\n",
" <td>North York</td>\n",
" <td>Regent Park, Lawrence Heights</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>M6A</td>\n",
" <td>North York</td>\n",
" <td>Lawrence Manor</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>M7A</td>\n",
" <td>Queen's Park</td>\n",
" <td>Lawrence Manor, Queen's Park</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>M9A</td>\n",
" <td>Etobicoke</td>\n",
" <td>Lawrence Manor, Queen's Park, Islington Avenue</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>M1B</td>\n",
" <td>Scarborough</td>\n",
" <td>Lawrence Manor, Queen's Park, Islington Avenue...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>M1B</td>\n",
" <td>Scarborough</td>\n",
" <td>Malvern</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>M3B</td>\n",
" <td>North York</td>\n",
" <td>Malvern, Don Mills North</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>M4B</td>\n",
" <td>East York</td>\n",
" <td>Malvern, Don Mills North, Woodbine Gardens</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>M4B</td>\n",
" <td>East York</td>\n",
" <td>Parkview Hill</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>M5B</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Parkview Hill, Ryerson</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>M5B</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Garden District</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>M6B</td>\n",
" <td>North York</td>\n",
" <td>Garden District, Glencairn</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>M9B</td>\n",
" <td>Etobicoke</td>\n",
" <td>Garden District, Glencairn, Cloverdale</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>M9B</td>\n",
" <td>Etobicoke</td>\n",
" <td>Islington</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>M9B</td>\n",
" <td>Etobicoke</td>\n",
" <td>Martin Grove</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>M9B</td>\n",
" <td>Etobicoke</td>\n",
" <td>Princess Gardens</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>M9B</td>\n",
" <td>Etobicoke</td>\n",
" <td>West Deane Park</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>M1C</td>\n",
" <td>Scarborough</td>\n",
" <td>West Deane Park, Highland Creek</td>\n",
" </tr>\n",
" <tr>\n",
" <th>29</th>\n",
" <td>M1C</td>\n",
" <td>Scarborough</td>\n",
" <td>Rouge Hill</td>\n",
" </tr>\n",
" <tr>\n",
" <th>30</th>\n",
" <td>M1C</td>\n",
" <td>Scarborough</td>\n",
" <td>Port Union</td>\n",
" </tr>\n",
" <tr>\n",
" <th>32</th>\n",
" <td>M3C</td>\n",
" <td>North York</td>\n",
" <td>Port Union, Flemingdon Park</td>\n",
" </tr>\n",
" <tr>\n",
" <th>33</th>\n",
" <td>M3C</td>\n",
" <td>North York</td>\n",
" <td>Don Mills South</td>\n",
" </tr>\n",
" <tr>\n",
" <th>34</th>\n",
" <td>M4C</td>\n",
" <td>East York</td>\n",
" <td>Don Mills South, Woodbine Heights</td>\n",
" </tr>\n",
" <tr>\n",
" <th>35</th>\n",
" <td>M5C</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Don Mills South, Woodbine Heights, St. James Town</td>\n",
" </tr>\n",
" <tr>\n",
" <th>36</th>\n",
" <td>M6C</td>\n",
" <td>York</td>\n",
" <td>Don Mills South, Woodbine Heights, St. James T...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>39</th>\n",
" <td>M9C</td>\n",
" <td>Etobicoke</td>\n",
" <td>Don Mills South, Woodbine Heights, St. James T...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>237</th>\n",
" <td>M1W</td>\n",
" <td>Scarborough</td>\n",
" <td>Thistletown, L'Amoreaux West</td>\n",
" </tr>\n",
" <tr>\n",
" <th>238</th>\n",
" <td>M1W</td>\n",
" <td>Scarborough</td>\n",
" <td>Steeles West</td>\n",
" </tr>\n",
" <tr>\n",
" <th>241</th>\n",
" <td>M4W</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Steeles West, Rosedale</td>\n",
" </tr>\n",
" <tr>\n",
" <th>242</th>\n",
" <td>M5W</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Steeles West, Rosedale, Stn A PO Boxes 25 The ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>245</th>\n",
" <td>M8W</td>\n",
" <td>Etobicoke</td>\n",
" <td>Steeles West, Rosedale, Stn A PO Boxes 25 The ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>246</th>\n",
" <td>M8W</td>\n",
" <td>Etobicoke</td>\n",
" <td>Long Branch</td>\n",
" </tr>\n",
" <tr>\n",
" <th>247</th>\n",
" <td>M9W</td>\n",
" <td>Etobicoke</td>\n",
" <td>Long Branch, Northwest</td>\n",
" </tr>\n",
" <tr>\n",
" <th>248</th>\n",
" <td>M1X</td>\n",
" <td>Scarborough</td>\n",
" <td>Long Branch, Northwest, Upper Rouge</td>\n",
" </tr>\n",
" <tr>\n",
" <th>251</th>\n",
" <td>M4X</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Long Branch, Northwest, Upper Rouge, Cabbagetown</td>\n",
" </tr>\n",
" <tr>\n",
" <th>252</th>\n",
" <td>M4X</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>St. James Town</td>\n",
" </tr>\n",
" <tr>\n",
" <th>253</th>\n",
" <td>M5X</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>St. James Town, First Canadian Place</td>\n",
" </tr>\n",
" <tr>\n",
" <th>254</th>\n",
" <td>M5X</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Underground city</td>\n",
" </tr>\n",
" <tr>\n",
" <th>257</th>\n",
" <td>M8X</td>\n",
" <td>Etobicoke</td>\n",
" <td>Underground city, The Kingsway</td>\n",
" </tr>\n",
" <tr>\n",
" <th>258</th>\n",
" <td>M8X</td>\n",
" <td>Etobicoke</td>\n",
" <td>Montgomery Road</td>\n",
" </tr>\n",
" <tr>\n",
" <th>259</th>\n",
" <td>M8X</td>\n",
" <td>Etobicoke</td>\n",
" <td>Old Mill North</td>\n",
" </tr>\n",
" <tr>\n",
" <th>264</th>\n",
" <td>M4Y</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Old Mill North, Church and Wellesley</td>\n",
" </tr>\n",
" <tr>\n",
" <th>267</th>\n",
" <td>M7Y</td>\n",
" <td>East Toronto</td>\n",
" <td>Old Mill North, Church and Wellesley, Business...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>268</th>\n",
" <td>M8Y</td>\n",
" <td>Etobicoke</td>\n",
" <td>Old Mill North, Church and Wellesley, Business...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>269</th>\n",
" <td>M8Y</td>\n",
" <td>Etobicoke</td>\n",
" <td>King's Mill Park</td>\n",
" </tr>\n",
" <tr>\n",
" <th>270</th>\n",
" <td>M8Y</td>\n",
" <td>Etobicoke</td>\n",
" <td>Kingsway Park South East</td>\n",
" </tr>\n",
" <tr>\n",
" <th>271</th>\n",
" <td>M8Y</td>\n",
" <td>Etobicoke</td>\n",
" <td>Mimico NE</td>\n",
" </tr>\n",
" <tr>\n",
" <th>272</th>\n",
" <td>M8Y</td>\n",
" <td>Etobicoke</td>\n",
" <td>Old Mill South</td>\n",
" </tr>\n",
" <tr>\n",
" <th>273</th>\n",
" <td>M8Y</td>\n",
" <td>Etobicoke</td>\n",
" <td>The Queensway East</td>\n",
" </tr>\n",
" <tr>\n",
" <th>274</th>\n",
" <td>M8Y</td>\n",
" <td>Etobicoke</td>\n",
" <td>Royal York South East</td>\n",
" </tr>\n",
" <tr>\n",
" <th>275</th>\n",
" <td>M8Y</td>\n",
" <td>Etobicoke</td>\n",
" <td>Sunnylea</td>\n",
" </tr>\n",
" <tr>\n",
" <th>284</th>\n",
" <td>M8Z</td>\n",
" <td>Etobicoke</td>\n",
" <td>Sunnylea, Kingsway Park South West</td>\n",
" </tr>\n",
" <tr>\n",
" <th>285</th>\n",
" <td>M8Z</td>\n",
" <td>Etobicoke</td>\n",
" <td>Mimico NW</td>\n",
" </tr>\n",
" <tr>\n",
" <th>286</th>\n",
" <td>M8Z</td>\n",
" <td>Etobicoke</td>\n",
" <td>The Queensway West</td>\n",
" </tr>\n",
" <tr>\n",
" <th>287</th>\n",
" <td>M8Z</td>\n",
" <td>Etobicoke</td>\n",
" <td>Royal York South West</td>\n",
" </tr>\n",
" <tr>\n",
" <th>288</th>\n",
" <td>M8Z</td>\n",
" <td>Etobicoke</td>\n",
" <td>South of Bloor</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>212 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" PostalCode Borough \\\n",
"3 M3A North York \n",
"4 M4A North York \n",
"5 M5A Downtown Toronto \n",
"6 M5A Downtown Toronto \n",
"7 M6A North York \n",
"8 M6A North York \n",
"9 M7A Queen's Park \n",
"11 M9A Etobicoke \n",
"12 M1B Scarborough \n",
"13 M1B Scarborough \n",
"15 M3B North York \n",
"16 M4B East York \n",
"17 M4B East York \n",
"18 M5B Downtown Toronto \n",
"19 M5B Downtown Toronto \n",
"20 M6B North York \n",
"23 M9B Etobicoke \n",
"24 M9B Etobicoke \n",
"25 M9B Etobicoke \n",
"26 M9B Etobicoke \n",
"27 M9B Etobicoke \n",
"28 M1C Scarborough \n",
"29 M1C Scarborough \n",
"30 M1C Scarborough \n",
"32 M3C North York \n",
"33 M3C North York \n",
"34 M4C East York \n",
"35 M5C Downtown Toronto \n",
"36 M6C York \n",
"39 M9C Etobicoke \n",
".. ... ... \n",
"237 M1W Scarborough \n",
"238 M1W Scarborough \n",
"241 M4W Downtown Toronto \n",
"242 M5W Downtown Toronto \n",
"245 M8W Etobicoke \n",
"246 M8W Etobicoke \n",
"247 M9W Etobicoke \n",
"248 M1X Scarborough \n",
"251 M4X Downtown Toronto \n",
"252 M4X Downtown Toronto \n",
"253 M5X Downtown Toronto \n",
"254 M5X Downtown Toronto \n",
"257 M8X Etobicoke \n",
"258 M8X Etobicoke \n",
"259 M8X Etobicoke \n",
"264 M4Y Downtown Toronto \n",
"267 M7Y East Toronto \n",
"268 M8Y Etobicoke \n",
"269 M8Y Etobicoke \n",
"270 M8Y Etobicoke \n",
"271 M8Y Etobicoke \n",
"272 M8Y Etobicoke \n",
"273 M8Y Etobicoke \n",
"274 M8Y Etobicoke \n",
"275 M8Y Etobicoke \n",
"284 M8Z Etobicoke \n",
"285 M8Z Etobicoke \n",
"286 M8Z Etobicoke \n",
"287 M8Z Etobicoke \n",
"288 M8Z Etobicoke \n",
"\n",
" Neighborhood \n",
"3 , Parkwoods \n",
"4 , Parkwoods, Victoria Village \n",
"5 , Parkwoods, Victoria Village, Harbourfront \n",
"6 Regent Park \n",
"7 Regent Park, Lawrence Heights \n",
"8 Lawrence Manor \n",
"9 Lawrence Manor, Queen's Park \n",
"11 Lawrence Manor, Queen's Park, Islington Avenue \n",
"12 Lawrence Manor, Queen's Park, Islington Avenue... \n",
"13 Malvern \n",
"15 Malvern, Don Mills North \n",
"16 Malvern, Don Mills North, Woodbine Gardens \n",
"17 Parkview Hill \n",
"18 Parkview Hill, Ryerson \n",
"19 Garden District \n",
"20 Garden District, Glencairn \n",
"23 Garden District, Glencairn, Cloverdale \n",
"24 Islington \n",
"25 Martin Grove \n",
"26 Princess Gardens \n",
"27 West Deane Park \n",
"28 West Deane Park, Highland Creek \n",
"29 Rouge Hill \n",
"30 Port Union \n",
"32 Port Union, Flemingdon Park \n",
"33 Don Mills South \n",
"34 Don Mills South, Woodbine Heights \n",
"35 Don Mills South, Woodbine Heights, St. James Town \n",
"36 Don Mills South, Woodbine Heights, St. James T... \n",
"39 Don Mills South, Woodbine Heights, St. James T... \n",
".. ... \n",
"237 Thistletown, L'Amoreaux West \n",
"238 Steeles West \n",
"241 Steeles West, Rosedale \n",
"242 Steeles West, Rosedale, Stn A PO Boxes 25 The ... \n",
"245 Steeles West, Rosedale, Stn A PO Boxes 25 The ... \n",
"246 Long Branch \n",
"247 Long Branch, Northwest \n",
"248 Long Branch, Northwest, Upper Rouge \n",
"251 Long Branch, Northwest, Upper Rouge, Cabbagetown \n",
"252 St. James Town \n",
"253 St. James Town, First Canadian Place \n",
"254 Underground city \n",
"257 Underground city, The Kingsway \n",
"258 Montgomery Road \n",
"259 Old Mill North \n",
"264 Old Mill North, Church and Wellesley \n",
"267 Old Mill North, Church and Wellesley, Business... \n",
"268 Old Mill North, Church and Wellesley, Business... \n",
"269 King's Mill Park \n",
"270 Kingsway Park South East \n",
"271 Mimico NE \n",
"272 Old Mill South \n",
"273 The Queensway East \n",
"274 Royal York South East \n",
"275 Sunnylea \n",
"284 Sunnylea, Kingsway Park South West \n",
"285 Mimico NW \n",
"286 The Queensway West \n",
"287 Royal York South West \n",
"288 South of Bloor \n",
"\n",
"[212 rows x 3 columns]"
]
},
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# extract the postal code table\n",
"postal_data = []\n",
"table = soup.find('table', attrs={'class':'wikitable sortable'})\n",
"table_body = table.find('tbody')\n",
"\n",
"rows = table_body.find_all('tr')\n",
"for row in rows:\n",
" cols = row.find_all('td')\n",
" cols = [ele.text.strip() for ele in cols]\n",
" postal_data.append([ele for ele in cols if ele]) # Get rid of empty values\n",
"\n",
"# the resulted is a list, so let us convert it to dataframe \n",
"df = pd.DataFrame(data=postal_data)\n",
"\n",
"# assign proper headers to columns\n",
"df.columns = ['PostalCode', 'Borough', 'Neighborhood']\n",
"\n",
"# Ignore cells with a borough that is Not assigned. \n",
"df_new = df [df.Borough != \"Not assigned\"]\n",
"\n",
"# If a cell has a borough but a Not assigned neighborhood, then the neighborhood will be the same as the borough\n",
"for index, row in df_new.iterrows():\n",
" if row[\"Neighborhood\"] == \"Not assigned\" :\n",
" row[\"Neighborhood\"] = row[\"Borough\"]\n",
"\n",
"# let us sort dataframe by column 'PostalCode', thus we can handle the next process\n",
"df_new.sort_values(by=['PostalCode'])\n",
"# delete first row conducted by parser as empty\n",
"df_new = df_new.iloc[1:]\n",
"\n",
"# More than one neighborhood can exist in one postal code area\n",
"# let us comine these neighbors into one row\n",
"old_postal_code = ''\n",
"old_neighborhood = ''\n",
"\n",
"\n",
"for index, row in df_new.iterrows():\n",
" \n",
" if old_postal_code == row[\"PostalCode\"]:\n",
" old_postal_code = old_postal_code\n",
" elif old_postal_code != row[\"PostalCode\"]:\n",
" row[\"Neighborhood\"] = old_neighborhood + ', ' + row[\"Neighborhood\"]\n",
" old_postal_code = row[\"PostalCode\"]\n",
" old_neighborhood = row[\"Neighborhood\"]\n",
"\n",
"print ('Our dataframe now is ' + str (df_new.shape[0]) + \" rows\")\n",
"df_new\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 77,
"metadata": {},
"outputs": [],
"source": [
"geocsv = pd.read_csv(\"https://cocl.us/Geospatial_data\")"
]
},
{
"cell_type": "code",
"execution_count": 78,
"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>Postal Code</th>\n",
" <th>Latitude</th>\n",
" <th>Longitude</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>M1B</td>\n",
" <td>43.806686</td>\n",
" <td>-79.194353</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>M1C</td>\n",
" <td>43.784535</td>\n",
" <td>-79.160497</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>M1E</td>\n",
" <td>43.763573</td>\n",
" <td>-79.188711</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>M1G</td>\n",
" <td>43.770992</td>\n",
" <td>-79.216917</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>M1H</td>\n",
" <td>43.773136</td>\n",
" <td>-79.239476</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>M1J</td>\n",
" <td>43.744734</td>\n",
" <td>-79.239476</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>M1K</td>\n",
" <td>43.727929</td>\n",
" <td>-79.262029</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>M1L</td>\n",
" <td>43.711112</td>\n",
" <td>-79.284577</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>M1M</td>\n",
" <td>43.716316</td>\n",
" <td>-79.239476</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>M1N</td>\n",
" <td>43.692657</td>\n",
" <td>-79.264848</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>M1P</td>\n",
" <td>43.757410</td>\n",
" <td>-79.273304</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>M1R</td>\n",
" <td>43.750072</td>\n",
" <td>-79.295849</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>M1S</td>\n",
" <td>43.794200</td>\n",
" <td>-79.262029</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>M1T</td>\n",
" <td>43.781638</td>\n",
" <td>-79.304302</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>M1V</td>\n",
" <td>43.815252</td>\n",
" <td>-79.284577</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>M1W</td>\n",
" <td>43.799525</td>\n",
" <td>-79.318389</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>M1X</td>\n",
" <td>43.836125</td>\n",
" <td>-79.205636</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>M2H</td>\n",
" <td>43.803762</td>\n",
" <td>-79.363452</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>M2J</td>\n",
" <td>43.778517</td>\n",
" <td>-79.346556</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>M2K</td>\n",
" <td>43.786947</td>\n",
" <td>-79.385975</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>M2L</td>\n",
" <td>43.757490</td>\n",
" <td>-79.374714</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>M2M</td>\n",
" <td>43.789053</td>\n",
" <td>-79.408493</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>M2N</td>\n",
" <td>43.770120</td>\n",
" <td>-79.408493</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>M2P</td>\n",
" <td>43.752758</td>\n",
" <td>-79.400049</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>M2R</td>\n",
" <td>43.782736</td>\n",
" <td>-79.442259</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>M3A</td>\n",
" <td>43.753259</td>\n",
" <td>-79.329656</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>M3B</td>\n",
" <td>43.745906</td>\n",
" <td>-79.352188</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>M3C</td>\n",
" <td>43.725900</td>\n",
" <td>-79.340923</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>M3H</td>\n",
" <td>43.754328</td>\n",
" <td>-79.442259</td>\n",
" </tr>\n",
" <tr>\n",
" <th>29</th>\n",
" <td>M3J</td>\n",
" <td>43.767980</td>\n",
" <td>-79.487262</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>73</th>\n",
" <td>M6C</td>\n",
" <td>43.693781</td>\n",
" <td>-79.428191</td>\n",
" </tr>\n",
" <tr>\n",
" <th>74</th>\n",
" <td>M6E</td>\n",
" <td>43.689026</td>\n",
" <td>-79.453512</td>\n",
" </tr>\n",
" <tr>\n",
" <th>75</th>\n",
" <td>M6G</td>\n",
" <td>43.669542</td>\n",
" <td>-79.422564</td>\n",
" </tr>\n",
" <tr>\n",
" <th>76</th>\n",
" <td>M6H</td>\n",
" <td>43.669005</td>\n",
" <td>-79.442259</td>\n",
" </tr>\n",
" <tr>\n",
" <th>77</th>\n",
" <td>M6J</td>\n",
" <td>43.647927</td>\n",
" <td>-79.419750</td>\n",
" </tr>\n",
" <tr>\n",
" <th>78</th>\n",
" <td>M6K</td>\n",
" <td>43.636847</td>\n",
" <td>-79.428191</td>\n",
" </tr>\n",
" <tr>\n",
" <th>79</th>\n",
" <td>M6L</td>\n",
" <td>43.713756</td>\n",
" <td>-79.490074</td>\n",
" </tr>\n",
" <tr>\n",
" <th>80</th>\n",
" <td>M6M</td>\n",
" <td>43.691116</td>\n",
" <td>-79.476013</td>\n",
" </tr>\n",
" <tr>\n",
" <th>81</th>\n",
" <td>M6N</td>\n",
" <td>43.673185</td>\n",
" <td>-79.487262</td>\n",
" </tr>\n",
" <tr>\n",
" <th>82</th>\n",
" <td>M6P</td>\n",
" <td>43.661608</td>\n",
" <td>-79.464763</td>\n",
" </tr>\n",
" <tr>\n",
" <th>83</th>\n",
" <td>M6R</td>\n",
" <td>43.648960</td>\n",
" <td>-79.456325</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84</th>\n",
" <td>M6S</td>\n",
" <td>43.651571</td>\n",
" <td>-79.484450</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85</th>\n",
" <td>M7A</td>\n",
" <td>43.662301</td>\n",
" <td>-79.389494</td>\n",
" </tr>\n",
" <tr>\n",
" <th>86</th>\n",
" <td>M7R</td>\n",
" <td>43.636966</td>\n",
" <td>-79.615819</td>\n",
" </tr>\n",
" <tr>\n",
" <th>87</th>\n",
" <td>M7Y</td>\n",
" <td>43.662744</td>\n",
" <td>-79.321558</td>\n",
" </tr>\n",
" <tr>\n",
" <th>88</th>\n",
" <td>M8V</td>\n",
" <td>43.605647</td>\n",
" <td>-79.501321</td>\n",
" </tr>\n",
" <tr>\n",
" <th>89</th>\n",
" <td>M8W</td>\n",
" <td>43.602414</td>\n",
" <td>-79.543484</td>\n",
" </tr>\n",
" <tr>\n",
" <th>90</th>\n",
" <td>M8X</td>\n",
" <td>43.653654</td>\n",
" <td>-79.506944</td>\n",
" </tr>\n",
" <tr>\n",
" <th>91</th>\n",
" <td>M8Y</td>\n",
" <td>43.636258</td>\n",
" <td>-79.498509</td>\n",
" </tr>\n",
" <tr>\n",
" <th>92</th>\n",
" <td>M8Z</td>\n",
" <td>43.628841</td>\n",
" <td>-79.520999</td>\n",
" </tr>\n",
" <tr>\n",
" <th>93</th>\n",
" <td>M9A</td>\n",
" <td>43.667856</td>\n",
" <td>-79.532242</td>\n",
" </tr>\n",
" <tr>\n",
" <th>94</th>\n",
" <td>M9B</td>\n",
" <td>43.650943</td>\n",
" <td>-79.554724</td>\n",
" </tr>\n",
" <tr>\n",
" <th>95</th>\n",
" <td>M9C</td>\n",
" <td>43.643515</td>\n",
" <td>-79.577201</td>\n",
" </tr>\n",
" <tr>\n",
" <th>96</th>\n",
" <td>M9L</td>\n",
" <td>43.756303</td>\n",
" <td>-79.565963</td>\n",
" </tr>\n",
" <tr>\n",
" <th>97</th>\n",
" <td>M9M</td>\n",
" <td>43.724766</td>\n",
" <td>-79.532242</td>\n",
" </tr>\n",
" <tr>\n",
" <th>98</th>\n",
" <td>M9N</td>\n",
" <td>43.706876</td>\n",
" <td>-79.518188</td>\n",
" </tr>\n",
" <tr>\n",
" <th>99</th>\n",
" <td>M9P</td>\n",
" <td>43.696319</td>\n",
" <td>-79.532242</td>\n",
" </tr>\n",
" <tr>\n",
" <th>100</th>\n",
" <td>M9R</td>\n",
" <td>43.688905</td>\n",
" <td>-79.554724</td>\n",
" </tr>\n",
" <tr>\n",
" <th>101</th>\n",
" <td>M9V</td>\n",
" <td>43.739416</td>\n",
" <td>-79.588437</td>\n",
" </tr>\n",
" <tr>\n",
" <th>102</th>\n",
" <td>M9W</td>\n",
" <td>43.706748</td>\n",
" <td>-79.594054</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>103 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" Postal Code Latitude Longitude\n",
"0 M1B 43.806686 -79.194353\n",
"1 M1C 43.784535 -79.160497\n",
"2 M1E 43.763573 -79.188711\n",
"3 M1G 43.770992 -79.216917\n",
"4 M1H 43.773136 -79.239476\n",
"5 M1J 43.744734 -79.239476\n",
"6 M1K 43.727929 -79.262029\n",
"7 M1L 43.711112 -79.284577\n",
"8 M1M 43.716316 -79.239476\n",
"9 M1N 43.692657 -79.264848\n",
"10 M1P 43.757410 -79.273304\n",
"11 M1R 43.750072 -79.295849\n",
"12 M1S 43.794200 -79.262029\n",
"13 M1T 43.781638 -79.304302\n",
"14 M1V 43.815252 -79.284577\n",
"15 M1W 43.799525 -79.318389\n",
"16 M1X 43.836125 -79.205636\n",
"17 M2H 43.803762 -79.363452\n",
"18 M2J 43.778517 -79.346556\n",
"19 M2K 43.786947 -79.385975\n",
"20 M2L 43.757490 -79.374714\n",
"21 M2M 43.789053 -79.408493\n",
"22 M2N 43.770120 -79.408493\n",
"23 M2P 43.752758 -79.400049\n",
"24 M2R 43.782736 -79.442259\n",
"25 M3A 43.753259 -79.329656\n",
"26 M3B 43.745906 -79.352188\n",
"27 M3C 43.725900 -79.340923\n",
"28 M3H 43.754328 -79.442259\n",
"29 M3J 43.767980 -79.487262\n",
".. ... ... ...\n",
"73 M6C 43.693781 -79.428191\n",
"74 M6E 43.689026 -79.453512\n",
"75 M6G 43.669542 -79.422564\n",
"76 M6H 43.669005 -79.442259\n",
"77 M6J 43.647927 -79.419750\n",
"78 M6K 43.636847 -79.428191\n",
"79 M6L 43.713756 -79.490074\n",
"80 M6M 43.691116 -79.476013\n",
"81 M6N 43.673185 -79.487262\n",
"82 M6P 43.661608 -79.464763\n",
"83 M6R 43.648960 -79.456325\n",
"84 M6S 43.651571 -79.484450\n",
"85 M7A 43.662301 -79.389494\n",
"86 M7R 43.636966 -79.615819\n",
"87 M7Y 43.662744 -79.321558\n",
"88 M8V 43.605647 -79.501321\n",
"89 M8W 43.602414 -79.543484\n",
"90 M8X 43.653654 -79.506944\n",
"91 M8Y 43.636258 -79.498509\n",
"92 M8Z 43.628841 -79.520999\n",
"93 M9A 43.667856 -79.532242\n",
"94 M9B 43.650943 -79.554724\n",
"95 M9C 43.643515 -79.577201\n",
"96 M9L 43.756303 -79.565963\n",
"97 M9M 43.724766 -79.532242\n",
"98 M9N 43.706876 -79.518188\n",
"99 M9P 43.696319 -79.532242\n",
"100 M9R 43.688905 -79.554724\n",
"101 M9V 43.739416 -79.588437\n",
"102 M9W 43.706748 -79.594054\n",
"\n",
"[103 rows x 3 columns]"
]
},
"execution_count": 78,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"geocsv"
]
},
{
"cell_type": "code",
"execution_count": 86,
"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>PostalCode</th>\n",
" <th>Borough</th>\n",
" <th>Neighborhood</th>\n",
" <th>Latitude</th>\n",
" <th>Longitude</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>M3A</td>\n",
" <td>North York</td>\n",
" <td>, Parkwoods</td>\n",
" <td>43.770992</td>\n",
" <td>-79.216917</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>M4A</td>\n",
" <td>North York</td>\n",
" <td>, Parkwoods, Victoria Village</td>\n",
" <td>43.773136</td>\n",
" <td>-79.239476</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>M5A</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>, Parkwoods, Victoria Village, Harbourfront</td>\n",
" <td>43.744734</td>\n",
" <td>-79.239476</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>M5A</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Regent Park</td>\n",
" <td>43.727929</td>\n",
" <td>-79.262029</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>M6A</td>\n",
" <td>North York</td>\n",
" <td>Regent Park, Lawrence Heights</td>\n",
" <td>43.711112</td>\n",
" <td>-79.284577</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>M6A</td>\n",
" <td>North York</td>\n",
" <td>Lawrence Manor</td>\n",
" <td>43.716316</td>\n",
" <td>-79.239476</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>M7A</td>\n",
" <td>Queen's Park</td>\n",
" <td>Lawrence Manor, Queen's Park</td>\n",
" <td>43.692657</td>\n",
" <td>-79.264848</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>M9A</td>\n",
" <td>Etobicoke</td>\n",
" <td>Lawrence Manor, Queen's Park, Islington Avenue</td>\n",
" <td>43.750072</td>\n",
" <td>-79.295849</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>M1B</td>\n",
" <td>Scarborough</td>\n",
" <td>Lawrence Manor, Queen's Park, Islington Avenue...</td>\n",
" <td>43.794200</td>\n",
" <td>-79.262029</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>M1B</td>\n",
" <td>Scarborough</td>\n",
" <td>Malvern</td>\n",
" <td>43.781638</td>\n",
" <td>-79.304302</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>M3B</td>\n",
" <td>North York</td>\n",
" <td>Malvern, Don Mills North</td>\n",
" <td>43.799525</td>\n",
" <td>-79.318389</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>M4B</td>\n",
" <td>East York</td>\n",
" <td>Malvern, Don Mills North, Woodbine Gardens</td>\n",
" <td>43.836125</td>\n",
" <td>-79.205636</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>M4B</td>\n",
" <td>East York</td>\n",
" <td>Parkview Hill</td>\n",
" <td>43.803762</td>\n",
" <td>-79.363452</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>M5B</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Parkview Hill, Ryerson</td>\n",
" <td>43.778517</td>\n",
" <td>-79.346556</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>M5B</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Garden District</td>\n",
" <td>43.786947</td>\n",
" <td>-79.385975</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>M6B</td>\n",
" <td>North York</td>\n",
" <td>Garden District, Glencairn</td>\n",
" <td>43.757490</td>\n",
" <td>-79.374714</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>M9B</td>\n",
" <td>Etobicoke</td>\n",
" <td>Garden District, Glencairn, Cloverdale</td>\n",
" <td>43.752758</td>\n",
" <td>-79.400049</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>M9B</td>\n",
" <td>Etobicoke</td>\n",
" <td>Islington</td>\n",
" <td>43.782736</td>\n",
" <td>-79.442259</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>M9B</td>\n",
" <td>Etobicoke</td>\n",
" <td>Martin Grove</td>\n",
" <td>43.753259</td>\n",
" <td>-79.329656</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>M9B</td>\n",
" <td>Etobicoke</td>\n",
" <td>Princess Gardens</td>\n",
" <td>43.745906</td>\n",
" <td>-79.352188</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>M9B</td>\n",
" <td>Etobicoke</td>\n",
" <td>West Deane Park</td>\n",
" <td>43.725900</td>\n",
" <td>-79.340923</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>M1C</td>\n",
" <td>Scarborough</td>\n",
" <td>West Deane Park, Highland Creek</td>\n",
" <td>43.754328</td>\n",
" <td>-79.442259</td>\n",
" </tr>\n",
" <tr>\n",
" <th>29</th>\n",
" <td>M1C</td>\n",
" <td>Scarborough</td>\n",
" <td>Rouge Hill</td>\n",
" <td>43.767980</td>\n",
" <td>-79.487262</td>\n",
" </tr>\n",
" <tr>\n",
" <th>30</th>\n",
" <td>M1C</td>\n",
" <td>Scarborough</td>\n",
" <td>Port Union</td>\n",
" <td>43.737473</td>\n",
" <td>-79.464763</td>\n",
" </tr>\n",
" <tr>\n",
" <th>32</th>\n",
" <td>M3C</td>\n",
" <td>North York</td>\n",
" <td>Port Union, Flemingdon Park</td>\n",
" <td>43.728496</td>\n",
" <td>-79.495697</td>\n",
" </tr>\n",
" <tr>\n",
" <th>33</th>\n",
" <td>M3C</td>\n",
" <td>North York</td>\n",
" <td>Don Mills South</td>\n",
" <td>43.761631</td>\n",
" <td>-79.520999</td>\n",
" </tr>\n",
" <tr>\n",
" <th>34</th>\n",
" <td>M4C</td>\n",
" <td>East York</td>\n",
" <td>Don Mills South, Woodbine Heights</td>\n",
" <td>43.725882</td>\n",
" <td>-79.315572</td>\n",
" </tr>\n",
" <tr>\n",
" <th>35</th>\n",
" <td>M5C</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Don Mills South, Woodbine Heights, St. James Town</td>\n",
" <td>43.706397</td>\n",
" <td>-79.309937</td>\n",
" </tr>\n",
" <tr>\n",
" <th>36</th>\n",
" <td>M6C</td>\n",
" <td>York</td>\n",
" <td>Don Mills South, Woodbine Heights, St. James T...</td>\n",
" <td>43.695344</td>\n",
" <td>-79.318389</td>\n",
" </tr>\n",
" <tr>\n",
" <th>39</th>\n",
" <td>M9C</td>\n",
" <td>Etobicoke</td>\n",
" <td>Don Mills South, Woodbine Heights, St. James T...</td>\n",
" <td>43.705369</td>\n",
" <td>-79.349372</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>237</th>\n",
" <td>M1W</td>\n",
" <td>Scarborough</td>\n",
" <td>Thistletown, L'Amoreaux West</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>238</th>\n",
" <td>M1W</td>\n",
" <td>Scarborough</td>\n",
" <td>Steeles West</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>241</th>\n",
" <td>M4W</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Steeles West, Rosedale</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>242</th>\n",
" <td>M5W</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Steeles West, Rosedale, Stn A PO Boxes 25 The ...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>245</th>\n",
" <td>M8W</td>\n",
" <td>Etobicoke</td>\n",
" <td>Steeles West, Rosedale, Stn A PO Boxes 25 The ...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>246</th>\n",
" <td>M8W</td>\n",
" <td>Etobicoke</td>\n",
" <td>Long Branch</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>247</th>\n",
" <td>M9W</td>\n",
" <td>Etobicoke</td>\n",
" <td>Long Branch, Northwest</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>248</th>\n",
" <td>M1X</td>\n",
" <td>Scarborough</td>\n",
" <td>Long Branch, Northwest, Upper Rouge</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>251</th>\n",
" <td>M4X</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Long Branch, Northwest, Upper Rouge, Cabbagetown</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>252</th>\n",
" <td>M4X</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>St. James Town</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>253</th>\n",
" <td>M5X</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>St. James Town, First Canadian Place</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>254</th>\n",
" <td>M5X</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Underground city</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>257</th>\n",
" <td>M8X</td>\n",
" <td>Etobicoke</td>\n",
" <td>Underground city, The Kingsway</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>258</th>\n",
" <td>M8X</td>\n",
" <td>Etobicoke</td>\n",
" <td>Montgomery Road</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>259</th>\n",
" <td>M8X</td>\n",
" <td>Etobicoke</td>\n",
" <td>Old Mill North</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>264</th>\n",
" <td>M4Y</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Old Mill North, Church and Wellesley</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>267</th>\n",
" <td>M7Y</td>\n",
" <td>East Toronto</td>\n",
" <td>Old Mill North, Church and Wellesley, Business...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>268</th>\n",
" <td>M8Y</td>\n",
" <td>Etobicoke</td>\n",
" <td>Old Mill North, Church and Wellesley, Business...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>269</th>\n",
" <td>M8Y</td>\n",
" <td>Etobicoke</td>\n",
" <td>King's Mill Park</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>270</th>\n",
" <td>M8Y</td>\n",
" <td>Etobicoke</td>\n",
" <td>Kingsway Park South East</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>271</th>\n",
" <td>M8Y</td>\n",
" <td>Etobicoke</td>\n",
" <td>Mimico NE</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>272</th>\n",
" <td>M8Y</td>\n",
" <td>Etobicoke</td>\n",
" <td>Old Mill South</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>273</th>\n",
" <td>M8Y</td>\n",
" <td>Etobicoke</td>\n",
" <td>The Queensway East</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>274</th>\n",
" <td>M8Y</td>\n",
" <td>Etobicoke</td>\n",
" <td>Royal York South East</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>275</th>\n",
" <td>M8Y</td>\n",
" <td>Etobicoke</td>\n",
" <td>Sunnylea</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>284</th>\n",
" <td>M8Z</td>\n",
" <td>Etobicoke</td>\n",
" <td>Sunnylea, Kingsway Park South West</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>285</th>\n",
" <td>M8Z</td>\n",
" <td>Etobicoke</td>\n",
" <td>Mimico NW</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>286</th>\n",
" <td>M8Z</td>\n",
" <td>Etobicoke</td>\n",
" <td>The Queensway West</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>287</th>\n",
" <td>M8Z</td>\n",
" <td>Etobicoke</td>\n",
" <td>Royal York South West</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>288</th>\n",
" <td>M8Z</td>\n",
" <td>Etobicoke</td>\n",
" <td>South of Bloor</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>212 rows × 5 columns</p>\n",
"</div>"
],
"text/plain": [
" PostalCode Borough \\\n",
"3 M3A North York \n",
"4 M4A North York \n",
"5 M5A Downtown Toronto \n",
"6 M5A Downtown Toronto \n",
"7 M6A North York \n",
"8 M6A North York \n",
"9 M7A Queen's Park \n",
"11 M9A Etobicoke \n",
"12 M1B Scarborough \n",
"13 M1B Scarborough \n",
"15 M3B North York \n",
"16 M4B East York \n",
"17 M4B East York \n",
"18 M5B Downtown Toronto \n",
"19 M5B Downtown Toronto \n",
"20 M6B North York \n",
"23 M9B Etobicoke \n",
"24 M9B Etobicoke \n",
"25 M9B Etobicoke \n",
"26 M9B Etobicoke \n",
"27 M9B Etobicoke \n",
"28 M1C Scarborough \n",
"29 M1C Scarborough \n",
"30 M1C Scarborough \n",
"32 M3C North York \n",
"33 M3C North York \n",
"34 M4C East York \n",
"35 M5C Downtown Toronto \n",
"36 M6C York \n",
"39 M9C Etobicoke \n",
".. ... ... \n",
"237 M1W Scarborough \n",
"238 M1W Scarborough \n",
"241 M4W Downtown Toronto \n",
"242 M5W Downtown Toronto \n",
"245 M8W Etobicoke \n",
"246 M8W Etobicoke \n",
"247 M9W Etobicoke \n",
"248 M1X Scarborough \n",
"251 M4X Downtown Toronto \n",
"252 M4X Downtown Toronto \n",
"253 M5X Downtown Toronto \n",
"254 M5X Downtown Toronto \n",
"257 M8X Etobicoke \n",
"258 M8X Etobicoke \n",
"259 M8X Etobicoke \n",
"264 M4Y Downtown Toronto \n",
"267 M7Y East Toronto \n",
"268 M8Y Etobicoke \n",
"269 M8Y Etobicoke \n",
"270 M8Y Etobicoke \n",
"271 M8Y Etobicoke \n",
"272 M8Y Etobicoke \n",
"273 M8Y Etobicoke \n",
"274 M8Y Etobicoke \n",
"275 M8Y Etobicoke \n",
"284 M8Z Etobicoke \n",
"285 M8Z Etobicoke \n",
"286 M8Z Etobicoke \n",
"287 M8Z Etobicoke \n",
"288 M8Z Etobicoke \n",
"\n",
" Neighborhood Latitude Longitude \n",
"3 , Parkwoods 43.770992 -79.216917 \n",
"4 , Parkwoods, Victoria Village 43.773136 -79.239476 \n",
"5 , Parkwoods, Victoria Village, Harbourfront 43.744734 -79.239476 \n",
"6 Regent Park 43.727929 -79.262029 \n",
"7 Regent Park, Lawrence Heights 43.711112 -79.284577 \n",
"8 Lawrence Manor 43.716316 -79.239476 \n",
"9 Lawrence Manor, Queen's Park 43.692657 -79.264848 \n",
"11 Lawrence Manor, Queen's Park, Islington Avenue 43.750072 -79.295849 \n",
"12 Lawrence Manor, Queen's Park, Islington Avenue... 43.794200 -79.262029 \n",
"13 Malvern 43.781638 -79.304302 \n",
"15 Malvern, Don Mills North 43.799525 -79.318389 \n",
"16 Malvern, Don Mills North, Woodbine Gardens 43.836125 -79.205636 \n",
"17 Parkview Hill 43.803762 -79.363452 \n",
"18 Parkview Hill, Ryerson 43.778517 -79.346556 \n",
"19 Garden District 43.786947 -79.385975 \n",
"20 Garden District, Glencairn 43.757490 -79.374714 \n",
"23 Garden District, Glencairn, Cloverdale 43.752758 -79.400049 \n",
"24 Islington 43.782736 -79.442259 \n",
"25 Martin Grove 43.753259 -79.329656 \n",
"26 Princess Gardens 43.745906 -79.352188 \n",
"27 West Deane Park 43.725900 -79.340923 \n",
"28 West Deane Park, Highland Creek 43.754328 -79.442259 \n",
"29 Rouge Hill 43.767980 -79.487262 \n",
"30 Port Union 43.737473 -79.464763 \n",
"32 Port Union, Flemingdon Park 43.728496 -79.495697 \n",
"33 Don Mills South 43.761631 -79.520999 \n",
"34 Don Mills South, Woodbine Heights 43.725882 -79.315572 \n",
"35 Don Mills South, Woodbine Heights, St. James Town 43.706397 -79.309937 \n",
"36 Don Mills South, Woodbine Heights, St. James T... 43.695344 -79.318389 \n",
"39 Don Mills South, Woodbine Heights, St. James T... 43.705369 -79.349372 \n",
".. ... ... ... \n",
"237 Thistletown, L'Amoreaux West NaN NaN \n",
"238 Steeles West NaN NaN \n",
"241 Steeles West, Rosedale NaN NaN \n",
"242 Steeles West, Rosedale, Stn A PO Boxes 25 The ... NaN NaN \n",
"245 Steeles West, Rosedale, Stn A PO Boxes 25 The ... NaN NaN \n",
"246 Long Branch NaN NaN \n",
"247 Long Branch, Northwest NaN NaN \n",
"248 Long Branch, Northwest, Upper Rouge NaN NaN \n",
"251 Long Branch, Northwest, Upper Rouge, Cabbagetown NaN NaN \n",
"252 St. James Town NaN NaN \n",
"253 St. James Town, First Canadian Place NaN NaN \n",
"254 Underground city NaN NaN \n",
"257 Underground city, The Kingsway NaN NaN \n",
"258 Montgomery Road NaN NaN \n",
"259 Old Mill North NaN NaN \n",
"264 Old Mill North, Church and Wellesley NaN NaN \n",
"267 Old Mill North, Church and Wellesley, Business... NaN NaN \n",
"268 Old Mill North, Church and Wellesley, Business... NaN NaN \n",
"269 King's Mill Park NaN NaN \n",
"270 Kingsway Park South East NaN NaN \n",
"271 Mimico NE NaN NaN \n",
"272 Old Mill South NaN NaN \n",
"273 The Queensway East NaN NaN \n",
"274 Royal York South East NaN NaN \n",
"275 Sunnylea NaN NaN \n",
"284 Sunnylea, Kingsway Park South West NaN NaN \n",
"285 Mimico NW NaN NaN \n",
"286 The Queensway West NaN NaN \n",
"287 Royal York South West NaN NaN \n",
"288 South of Bloor NaN NaN \n",
"\n",
"[212 rows x 5 columns]"
]
},
"execution_count": 86,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"for index, row in df_new.iterrows():\n",
" df_new['Latitude'] = geocsv['Latitude']\n",
" df_new['Longitude'] = geocsv['Longitude']\n",
" \n",
" \n",
"df_new"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"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.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment