Skip to content

Instantly share code, notes, and snippets.

@saishdesai23
Created August 30, 2019 15:28
Show Gist options
  • Save saishdesai23/533a7cb9fee24d2bb272c01743f61d6a to your computer and use it in GitHub Desktop.
Save saishdesai23/533a7cb9fee24d2bb272c01743f61d6a 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": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Solving environment: done\n",
"\n",
"\n",
"==> WARNING: A newer version of conda exists. <==\n",
" current version: 4.5.11\n",
" latest version: 4.7.11\n",
"\n",
"Please update conda by running\n",
"\n",
" $ conda update -n base -c defaults conda\n",
"\n",
"\n",
"\n",
"## Package Plan ##\n",
"\n",
" environment location: /home/jupyterlab/conda/envs/python\n",
"\n",
" added / updated specs: \n",
" - geopy\n",
"\n",
"\n",
"The following packages will be downloaded:\n",
"\n",
" package | build\n",
" ---------------------------|-----------------\n",
" geopy-1.20.0 | py_0 57 KB conda-forge\n",
" geographiclib-1.49 | py_0 32 KB conda-forge\n",
" ------------------------------------------------------------\n",
" Total: 90 KB\n",
"\n",
"The following NEW packages will be INSTALLED:\n",
"\n",
" geographiclib: 1.49-py_0 conda-forge\n",
" geopy: 1.20.0-py_0 conda-forge\n",
"\n",
"\n",
"Downloading and Extracting Packages\n",
"geopy-1.20.0 | 57 KB | ##################################### | 100% \n",
"geographiclib-1.49 | 32 KB | ##################################### | 100% \n",
"Preparing transaction: done\n",
"Verifying transaction: done\n",
"Executing transaction: done\n",
"Solving environment: done\n",
"\n",
"\n",
"==> WARNING: A newer version of conda exists. <==\n",
" current version: 4.5.11\n",
" latest version: 4.7.11\n",
"\n",
"Please update conda by running\n",
"\n",
" $ conda update -n base -c defaults conda\n",
"\n",
"\n",
"\n",
"# All requested packages already installed.\n",
"\n",
"Solving environment: done\n",
"\n",
"\n",
"==> WARNING: A newer version of conda exists. <==\n",
" current version: 4.5.11\n",
" latest version: 4.7.11\n",
"\n",
"Please update conda by running\n",
"\n",
" $ conda update -n base -c defaults conda\n",
"\n",
"\n",
"\n",
"## Package Plan ##\n",
"\n",
" environment location: /home/jupyterlab/conda/envs/python\n",
"\n",
" added / updated specs: \n",
" - beautifulsoup4\n",
"\n",
"\n",
"The following packages will be downloaded:\n",
"\n",
" package | build\n",
" ---------------------------|-----------------\n",
" soupsieve-1.9.3 | py36_0 57 KB conda-forge\n",
" beautifulsoup4-4.8.0 | py36_0 144 KB conda-forge\n",
" ------------------------------------------------------------\n",
" Total: 201 KB\n",
"\n",
"The following NEW packages will be INSTALLED:\n",
"\n",
" soupsieve: 1.9.3-py36_0 conda-forge\n",
"\n",
"The following packages will be UPDATED:\n",
"\n",
" beautifulsoup4: 4.6.3-py37_0 --> 4.8.0-py36_0 conda-forge\n",
"\n",
"\n",
"Downloading and Extracting Packages\n",
"soupsieve-1.9.3 | 57 KB | ##################################### | 100% \n",
"beautifulsoup4-4.8.0 | 144 KB | ##################################### | 100% \n",
"Preparing transaction: done\n",
"Verifying transaction: done\n",
"Executing transaction: done\n",
"Libraries imported.\n"
]
}
],
"source": [
"import numpy as np # library to handle data in a vectorized manner\n",
"import pandas as pd # library for data analsysis\n",
"\n",
"pd.set_option('display.max_columns', None)\n",
"pd.set_option('display.max_rows', None)\n",
"\n",
"import json # library to handle JSON files\n",
"\n",
"!conda install -c conda-forge geopy --yes # uncomment this line if you haven't completed the Foursquare API lab\n",
"from geopy.geocoders import Nominatim # convert an address into latitude and longitude values\n",
"\n",
"import requests # library to handle requests\n",
"from pandas.io.json import json_normalize # tranform JSON file into a pandas dataframe\n",
"\n",
"# Matplotlib and associated plotting modules\n",
"import matplotlib.cm as cm\n",
"import matplotlib.colors as colors\n",
"\n",
"# import k-means from clustering stage\n",
"from sklearn.cluster import KMeans\n",
"\n",
"!conda install -c conda-forge folium=0.5.0 --yes # uncomment this line if you haven't completed the Foursquare API lab\n",
"import folium # map rendering library\n",
"\n",
"!conda install -c conda-forge beautifulsoup4 --yes\n",
"\n",
"print('Libraries imported.')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<b>Step 1: After importing all the required libraries, we will perform a process called Web Scraping. In this process we will download the HTML data from the webpage under observation and extract the data from this page using the BeautifulSoup library.</b>"
]
},
{
"cell_type": "code",
"execution_count": 141,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The status code is 200\n",
"The webpage is successfully downloaded\n"
]
}
],
"source": [
"#Downloading HTML contents of the given web page\n",
"webpage = requests.get(\"https://en.wikipedia.org/wiki/List_of_postal_codes_of_Canada:_M\") #requesting the web server for HTML contents of a given web page\n",
"print(\"The status code is \",webpage.status_code) # if the status code is 200 then the web page is successfully downloaded\n",
"if (webpage.status_code == 200):\n",
" print(\"The webpage is successfully downloaded\")\n",
"else:\n",
" print(\"Failed to download the webpage\")\n",
"#print(\"HTML content of the Web page without parsing\")\n",
"#webpage.content"
]
},
{
"cell_type": "code",
"execution_count": 142,
"metadata": {},
"outputs": [],
"source": [
"#parsing the page and extracting the cotnents from p tag \n",
"from bs4 import BeautifulSoup\n",
"soup = BeautifulSoup(webpage.content, 'html.parser')\n",
"#print(soup.prettify())"
]
},
{
"cell_type": "code",
"execution_count": 143,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<table class=\"wikitable sortable\">\n",
"<tbody><tr>\n",
"<th>Postcode</th>\n",
"<th>Borough</th>\n",
"<th>Neighbourhood\n",
"</th></tr>\n",
"<tr>\n",
"<td>M1A</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2A</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3A</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Parkwoods\" title=\"Parkwoods\">Parkwoods</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4A</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Victoria_Village\" title=\"Victoria Village\">Victoria Village</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5A</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/Harbourfront_(Toronto)\" title=\"Harbourfront (Toronto)\">Harbourfront</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5A</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/Regent_Park\" title=\"Regent Park\">Regent Park</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6A</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Lawrence_Heights\" title=\"Lawrence Heights\">Lawrence Heights</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6A</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Lawrence_Manor\" title=\"Lawrence Manor\">Lawrence Manor</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7A</td>\n",
"<td><a href=\"/wiki/Queen%27s_Park_(Toronto)\" title=\"Queen's Park (Toronto)\">Queen's Park</a></td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8A</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9A</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Islington_Avenue\" title=\"Islington Avenue\">Islington Avenue</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1B</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Rouge,_Toronto\" title=\"Rouge, Toronto\">Rouge</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1B</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Malvern,_Toronto\" title=\"Malvern, Toronto\">Malvern</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2B</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3B</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td>Don Mills North\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4B</td>\n",
"<td><a href=\"/wiki/East_York\" title=\"East York\">East York</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Woodbine_Gardens\" title=\"Woodbine Gardens\">Woodbine Gardens</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4B</td>\n",
"<td><a href=\"/wiki/East_York\" title=\"East York\">East York</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Parkview_Hill\" title=\"Parkview Hill\">Parkview Hill</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5B</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td>Ryerson\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5B</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td>Garden District\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6B</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td>Glencairn\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7B</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8B</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9B</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Cloverdale\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9B</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Islington,_Toronto\" title=\"Islington, Toronto\">Islington</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9B</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Martin Grove\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9B</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a href=\"/wiki/Princess_Gardens\" title=\"Princess Gardens\">Princess Gardens</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9B</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/West_Deane_Park\" title=\"West Deane Park\">West Deane Park</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1C</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Highland_Creek_(Toronto)\" title=\"Highland Creek (Toronto)\">Highland Creek</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1C</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Rouge_Hill\" title=\"Rouge Hill\">Rouge Hill</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1C</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Port_Union,_Toronto\" title=\"Port Union, Toronto\">Port Union</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2C</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3C</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Flemingdon_Park\" title=\"Flemingdon Park\">Flemingdon Park</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3C</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td>Don Mills South\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4C</td>\n",
"<td><a href=\"/wiki/East_York\" title=\"East York\">East York</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Woodbine_Heights\" title=\"Woodbine Heights\">Woodbine Heights</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5C</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/St._James_Town\" title=\"St. James Town\">St. James Town</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6C</td>\n",
"<td>York</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Humewood-Cedarvale\" title=\"Humewood-Cedarvale\">Humewood-Cedarvale</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7C</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8C</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9C</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Bloordale Gardens\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9C</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Eringate\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9C</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a href=\"/wiki/Markland_Wood\" title=\"Markland Wood\">Markland Wood</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9C</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Old Burnhamthorpe\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1E</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td>Guildwood\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1E</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Morningside,_Toronto\" title=\"Morningside, Toronto\">Morningside</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1E</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/West_Hill,_Toronto\" title=\"West Hill, Toronto\">West Hill</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2E</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3E</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4E</td>\n",
"<td><a href=\"/wiki/East_Toronto\" title=\"East Toronto\">East Toronto</a></td>\n",
"<td><a href=\"/wiki/The_Beaches\" title=\"The Beaches\">The Beaches</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5E</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/Berczy_Park\" title=\"Berczy Park\">Berczy Park</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6E</td>\n",
"<td>York</td>\n",
"<td>Caledonia-Fairbanks\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7E</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8E</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9E</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1G</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Woburn,_Toronto\" title=\"Woburn, Toronto\">Woburn</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2G</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3G</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4G</td>\n",
"<td><a href=\"/wiki/East_York\" title=\"East York\">East York</a></td>\n",
"<td><a href=\"/wiki/Leaside\" title=\"Leaside\">Leaside</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5G</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td>Central Bay Street\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6G</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td>Christie\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7G</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8G</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9G</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1H</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td>Cedarbrae\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2H</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Hillcrest_Village\" title=\"Hillcrest Village\">Hillcrest Village</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3H</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Bathurst_Manor\" title=\"Bathurst Manor\">Bathurst Manor</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3H</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td>Downsview North\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3H</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Wilson_Heights,_Toronto\" title=\"Wilson Heights, Toronto\">Wilson Heights</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4H</td>\n",
"<td><a href=\"/wiki/East_York\" title=\"East York\">East York</a></td>\n",
"<td><a href=\"/wiki/Thorncliffe_Park\" title=\"Thorncliffe Park\">Thorncliffe Park</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5H</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td>Adelaide\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5H</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td>King\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5H</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td>Richmond\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6H</td>\n",
"<td><a href=\"/wiki/West_Toronto\" title=\"West Toronto\">West Toronto</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Dovercourt_Village\" title=\"Dovercourt Village\">Dovercourt Village</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6H</td>\n",
"<td><a href=\"/wiki/West_Toronto\" title=\"West Toronto\">West Toronto</a></td>\n",
"<td>Dufferin\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7H</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8H</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9H</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1J</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Scarborough_Village\" title=\"Scarborough Village\">Scarborough Village</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2J</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td>Fairview\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2J</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Henry_Farm\" title=\"Henry Farm\">Henry Farm</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2J</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td>Oriole\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3J</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Northwood_Park\" title=\"Northwood Park\">Northwood Park</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3J</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/York_University\" title=\"York University\">York University</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4J</td>\n",
"<td><a href=\"/wiki/East_York\" title=\"East York\">East York</a></td>\n",
"<td><a href=\"/wiki/East_Toronto\" title=\"East Toronto\">East Toronto</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5J</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td>Harbourfront East\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5J</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/Toronto_Islands\" title=\"Toronto Islands\">Toronto Islands</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5J</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/Union_Station_(Toronto)\" title=\"Union Station (Toronto)\">Union Station</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6J</td>\n",
"<td><a href=\"/wiki/West_Toronto\" title=\"West Toronto\">West Toronto</a></td>\n",
"<td><a href=\"/wiki/Little_Portugal,_Toronto\" title=\"Little Portugal, Toronto\">Little Portugal</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6J</td>\n",
"<td><a href=\"/wiki/West_Toronto\" title=\"West Toronto\">West Toronto</a></td>\n",
"<td><a href=\"/wiki/Trinity%E2%80%93Bellwoods\" title=\"Trinity–Bellwoods\">Trinity</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7J</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8J</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9J</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1K</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td>East Birchmount Park\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1K</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Ionview\" title=\"Ionview\">Ionview</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1K</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Kennedy_Park,_Toronto\" title=\"Kennedy Park, Toronto\">Kennedy Park</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2K</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Bayview_Village\" title=\"Bayview Village\">Bayview Village</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3K</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/CFB_Toronto\" title=\"CFB Toronto\">CFB Toronto</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3K</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td>Downsview East\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4K</td>\n",
"<td><a href=\"/wiki/East_Toronto\" title=\"East Toronto\">East Toronto</a></td>\n",
"<td>The Danforth West\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4K</td>\n",
"<td><a href=\"/wiki/East_Toronto\" title=\"East Toronto\">East Toronto</a></td>\n",
"<td><a href=\"/wiki/Riverdale,_Toronto\" title=\"Riverdale, Toronto\">Riverdale</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5K</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/Design_Exchange\" title=\"Design Exchange\">Design Exchange</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5K</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Toronto_Dominion_Centre\" title=\"Toronto Dominion Centre\">Toronto Dominion Centre</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6K</td>\n",
"<td><a href=\"/wiki/West_Toronto\" title=\"West Toronto\">West Toronto</a></td>\n",
"<td>Brockton\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6K</td>\n",
"<td><a href=\"/wiki/West_Toronto\" title=\"West Toronto\">West Toronto</a></td>\n",
"<td><a href=\"/wiki/Exhibition_Place\" title=\"Exhibition Place\">Exhibition Place</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6K</td>\n",
"<td><a href=\"/wiki/West_Toronto\" title=\"West Toronto\">West Toronto</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Parkdale_Village\" title=\"Parkdale Village\">Parkdale Village</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7K</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8K</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9K</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1L</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Clairlea\" title=\"Clairlea\">Clairlea</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1L</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Golden_Mile,_Toronto\" title=\"Golden Mile, Toronto\">Golden Mile</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1L</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Oakridge,_Toronto\" title=\"Oakridge, Toronto\">Oakridge</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2L</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td>Silver Hills\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2L</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/York_Mills\" title=\"York Mills\">York Mills</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3L</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Downsview\" title=\"Downsview\">Downsview West</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4L</td>\n",
"<td><a href=\"/wiki/East_Toronto\" title=\"East Toronto\">East Toronto</a></td>\n",
"<td>The Beaches West\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4L</td>\n",
"<td><a href=\"/wiki/East_Toronto\" title=\"East Toronto\">East Toronto</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/India_Bazaar\" title=\"India Bazaar\">India Bazaar</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5L</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/Commerce_Court\" title=\"Commerce Court\">Commerce Court</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5L</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td>Victoria Hotel\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6L</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Downsview,_Toronto\" title=\"Downsview, Toronto\">Downsview</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6L</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td>North Park\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6L</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td>Upwood Park\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7L</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8L</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9L</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Humber_Summit\" title=\"Humber Summit\">Humber Summit</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1M</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Cliffcrest\" title=\"Cliffcrest\">Cliffcrest</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1M</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Cliffside,_Toronto\" title=\"Cliffside, Toronto\">Cliffside</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1M</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td>Scarborough Village West\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2M</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Newtonbrook\" title=\"Newtonbrook\">Newtonbrook</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2M</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Willowdale,_Toronto\" title=\"Willowdale, Toronto\">Willowdale</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3M</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td>Downsview Central\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4M</td>\n",
"<td><a href=\"/wiki/East_Toronto\" title=\"East Toronto\">East Toronto</a></td>\n",
"<td>Studio District\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5M</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Bedford_Park,_Toronto\" title=\"Bedford Park, Toronto\">Bedford Park</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5M</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td>Lawrence Manor East\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6M</td>\n",
"<td><a href=\"/wiki/York,_Toronto\" title=\"York, Toronto\">York</a></td>\n",
"<td>Del Ray\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6M</td>\n",
"<td><a href=\"/wiki/York,_Toronto\" title=\"York, Toronto\">York</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Keelesdale\" title=\"Keelesdale\">Keelesdale</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6M</td>\n",
"<td><a href=\"/wiki/York,_Toronto\" title=\"York, Toronto\">York</a></td>\n",
"<td><a href=\"/wiki/Mount_Dennis\" title=\"Mount Dennis\">Mount Dennis</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6M</td>\n",
"<td><a href=\"/wiki/York,_Toronto\" title=\"York, Toronto\">York</a></td>\n",
"<td><a href=\"/wiki/Silverthorn,_Toronto\" title=\"Silverthorn, Toronto\">Silverthorn</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7M</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8M</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9M</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Emery,_Toronto\" title=\"Emery, Toronto\">Emery</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9M</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Humberlea\" title=\"Humberlea\">Humberlea</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1N</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Birch_Cliff\" title=\"Birch Cliff\">Birch Cliff</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1N</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td>Cliffside West\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2N</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td>Willowdale South\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3N</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td>Downsview Northwest\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4N</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Central_Toronto\" title=\"Central Toronto\">Central Toronto</a></td>\n",
"<td><a href=\"/wiki/Lawrence_Park,_Toronto\" title=\"Lawrence Park, Toronto\">Lawrence Park</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5N</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Central_Toronto\" title=\"Central Toronto\">Central Toronto</a></td>\n",
"<td>Roselawn\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6N</td>\n",
"<td><a href=\"/wiki/York,_Toronto\" title=\"York, Toronto\">York</a></td>\n",
"<td>The Junction North\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6N</td>\n",
"<td><a href=\"/wiki/York,_Toronto\" title=\"York, Toronto\">York</a></td>\n",
"<td>Runnymede\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7N</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8N</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9N</td>\n",
"<td><a href=\"/wiki/York,_Toronto\" title=\"York, Toronto\">York</a></td>\n",
"<td><a href=\"/wiki/Weston,_Toronto\" title=\"Weston, Toronto\">Weston</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1P</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Dorset_Park\" title=\"Dorset Park\">Dorset Park</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1P</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Scarborough_Town_Centre\" title=\"Scarborough Town Centre\">Scarborough Town Centre</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1P</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Wexford_Heights\" title=\"Wexford Heights\">Wexford Heights</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2P</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td>York Mills West\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3P</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4P</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Central_Toronto\" title=\"Central Toronto\">Central Toronto</a></td>\n",
"<td>Davisville North\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5P</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Central_Toronto\" title=\"Central Toronto\">Central Toronto</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Forest_Hill_North\" title=\"Forest Hill North\">Forest Hill North</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5P</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Central_Toronto\" title=\"Central Toronto\">Central Toronto</a></td>\n",
"<td>Forest Hill West\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6P</td>\n",
"<td><a href=\"/wiki/West_Toronto\" title=\"West Toronto\">West Toronto</a></td>\n",
"<td><a href=\"/wiki/High_Park\" title=\"High Park\">High Park</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6P</td>\n",
"<td><a href=\"/wiki/West_Toronto\" title=\"West Toronto\">West Toronto</a></td>\n",
"<td>The Junction South\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7P</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8P</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9P</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Westmount\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1R</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Maryvale,_Toronto\" title=\"Maryvale, Toronto\">Maryvale</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1R</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Wexford,_Toronto\" title=\"Wexford, Toronto\">Wexford</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2R</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Willowdale_West\" title=\"Willowdale West\">Willowdale West</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3R</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4R</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Central_Toronto\" title=\"Central Toronto\">Central Toronto</a></td>\n",
"<td>North Toronto West\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5R</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Central_Toronto\" title=\"Central Toronto\">Central Toronto</a></td>\n",
"<td><a href=\"/wiki/The_Annex\" title=\"The Annex\">The Annex</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5R</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Central_Toronto\" title=\"Central Toronto\">Central Toronto</a></td>\n",
"<td>North Midtown\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5R</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Central_Toronto\" title=\"Central Toronto\">Central Toronto</a></td>\n",
"<td><a href=\"/wiki/Yorkville,_Toronto\" title=\"Yorkville, Toronto\">Yorkville</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6R</td>\n",
"<td><a href=\"/wiki/West_Toronto\" title=\"West Toronto\">West Toronto</a></td>\n",
"<td><a href=\"/wiki/Parkdale,_Toronto\" title=\"Parkdale, Toronto\">Parkdale</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6R</td>\n",
"<td><a href=\"/wiki/West_Toronto\" title=\"West Toronto\">West Toronto</a></td>\n",
"<td><a href=\"/wiki/Roncesvalles,_Toronto\" title=\"Roncesvalles, Toronto\">Roncesvalles</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7R</td>\n",
"<td>Mississauga</td>\n",
"<td>Canada Post Gateway Processing Centre\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8R</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9R</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a href=\"/wiki/Kingsview_Village\" title=\"Kingsview Village\">Kingsview Village</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9R</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Martin Grove Gardens\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9R</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Richview Gardens\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9R</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>St. Phillips\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1S</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Agincourt,_Toronto\" title=\"Agincourt, Toronto\">Agincourt</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2S</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3S</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4S</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Central_Toronto\" title=\"Central Toronto\">Central Toronto</a></td>\n",
"<td>Davisville\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5S</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td>Harbord\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5S</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/University_of_Toronto\" title=\"University of Toronto\">University of Toronto</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6S</td>\n",
"<td><a href=\"/wiki/West_Toronto\" title=\"West Toronto\">West Toronto</a></td>\n",
"<td><a href=\"/wiki/Runnymede,_Toronto\" title=\"Runnymede, Toronto\">Runnymede</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6S</td>\n",
"<td><a href=\"/wiki/West_Toronto\" title=\"West Toronto\">West Toronto</a></td>\n",
"<td><a href=\"/wiki/Swansea,_Toronto\" title=\"Swansea, Toronto\">Swansea</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7S</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8S</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9S</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1T</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td>Clarks Corners\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1T</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td>Sullivan\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1T</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Tam_O%27Shanter_%E2%80%93_Sullivan\" title=\"Tam O'Shanter – Sullivan\">Tam O'Shanter</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2T</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3T</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4T</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Central_Toronto\" title=\"Central Toronto\">Central Toronto</a></td>\n",
"<td><a href=\"/wiki/Moore_Park,_Toronto\" title=\"Moore Park, Toronto\">Moore Park</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4T</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Central_Toronto\" title=\"Central Toronto\">Central Toronto</a></td>\n",
"<td>Summerhill East\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5T</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/Chinatown,_Toronto\" title=\"Chinatown, Toronto\">Chinatown</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5T</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/Grange_Park_(Toronto)\" title=\"Grange Park (Toronto)\">Grange Park</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5T</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/Kensington_Market\" title=\"Kensington Market\">Kensington Market</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6T</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7T</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8T</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9T</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1V</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Agincourt_North\" title=\"Agincourt North\">Agincourt North</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1V</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td>L'Amoreaux East\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1V</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a href=\"/wiki/Milliken,_Ontario\" title=\"Milliken, Ontario\">Milliken</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1V</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td>Steeles East\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2V</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3V</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4V</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Central_Toronto\" title=\"Central Toronto\">Central Toronto</a></td>\n",
"<td><a href=\"/wiki/Deer_Park,_Toronto\" title=\"Deer Park, Toronto\">Deer Park</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4V</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Central_Toronto\" title=\"Central Toronto\">Central Toronto</a></td>\n",
"<td>Forest Hill SE\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4V</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Central_Toronto\" title=\"Central Toronto\">Central Toronto</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Rathnelly\" title=\"Rathnelly\">Rathnelly</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4V</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Central_Toronto\" title=\"Central Toronto\">Central Toronto</a></td>\n",
"<td><a href=\"/wiki/South_Hill,_Toronto\" title=\"South Hill, Toronto\">South Hill</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4V</td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Central_Toronto\" title=\"Central Toronto\">Central Toronto</a></td>\n",
"<td>Summerhill West\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5V</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/CN_Tower\" title=\"CN Tower\">CN Tower</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5V</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td>Bathurst Quay\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5V</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td>Island airport\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5V</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td>Harbourfront West\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5V</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/King_and_Spadina\" title=\"King and Spadina\">King and Spadina</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5V</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/Railway_Lands\" title=\"Railway Lands\">Railway Lands</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5V</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/South_Niagara\" title=\"South Niagara\">South Niagara</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6V</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7V</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8V</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Humber Bay Shores\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8V</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Mimico South\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8V</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a href=\"/wiki/New_Toronto\" title=\"New Toronto\">New Toronto</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9V</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Albion Gardens\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9V</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Beaumond_Heights\" title=\"Beaumond Heights\">Beaumond Heights</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9V</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Humbergate\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9V</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Mount_Olive-Silverstone-Jamestown\" title=\"Mount Olive-Silverstone-Jamestown\">Jamestown</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9V</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Mount_Olive-Silverstone-Jamestown\" title=\"Mount Olive-Silverstone-Jamestown\">Mount Olive</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9V</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Silverstone,_Toronto\" title=\"Silverstone, Toronto\">Silverstone</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9V</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/South_Steeles\" title=\"South Steeles\">South Steeles</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9V</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a href=\"/wiki/Thistletown\" title=\"Thistletown\">Thistletown</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1W</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td>L'Amoreaux West\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2W</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3W</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4W</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/Rosedale,_Toronto\" title=\"Rosedale, Toronto\">Rosedale</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5W</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td>Stn A PO Boxes 25 The Esplanade\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6W</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7W</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8W</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a href=\"/wiki/Alderwood,_Toronto\" title=\"Alderwood, Toronto\">Alderwood</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8W</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a href=\"/wiki/Long_Branch,_Toronto\" title=\"Long Branch, Toronto\">Long Branch</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9W</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Northwest\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1X</td>\n",
"<td><a href=\"/wiki/Scarborough,_Toronto\" title=\"Scarborough, Toronto\">Scarborough</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Upper_Rouge\" title=\"Upper Rouge\">Upper Rouge</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2X</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3X</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4X</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/Cabbagetown,_Toronto\" title=\"Cabbagetown, Toronto\">Cabbagetown</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4X</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/St._James_Town\" title=\"St. James Town\">St. James Town</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5X</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/First_Canadian_Place\" title=\"First Canadian Place\">First Canadian Place</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5X</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/Underground_city\" title=\"Underground city\">Underground city</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6X</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7X</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8X</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a href=\"/wiki/The_Kingsway\" title=\"The Kingsway\">The Kingsway</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8X</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Montgomery Road\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8X</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Old Mill North\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9X</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1Y</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2Y</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3Y</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4Y</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/Church_and_Wellesley\" title=\"Church and Wellesley\">Church and Wellesley</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5Y</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6Y</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7Y</td>\n",
"<td><a href=\"/wiki/East_Toronto\" title=\"East Toronto\">East Toronto</a></td>\n",
"<td>Business Reply Mail Processing Centre 969 Eastern\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8Y</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a href=\"/wiki/Humber_Bay\" title=\"Humber Bay\">Humber Bay</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8Y</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>King's Mill Park\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8Y</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Kingsway Park South East\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8Y</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a href=\"/wiki/Mimico\" title=\"Mimico\">Mimico NE</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8Y</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a href=\"/wiki/Old_Mill,_Toronto\" title=\"Old Mill, Toronto\">Old Mill South</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8Y</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a href=\"/wiki/The_Queensway\" title=\"The Queensway\">The Queensway East</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8Y</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Fairmont_Royal_York_Hotel\" title=\"Fairmont Royal York Hotel\">Royal York South East</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8Y</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a class=\"mw-redirect\" href=\"/wiki/Sunnylea\" title=\"Sunnylea\">Sunnylea</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9Y</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M1Z</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M2Z</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M3Z</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M4Z</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M5Z</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M6Z</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M7Z</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8Z</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Kingsway Park South West\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8Z</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a href=\"/wiki/Mimico\" title=\"Mimico\">Mimico NW</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8Z</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td><a href=\"/wiki/The_Queensway\" title=\"The Queensway\">The Queensway West</a>\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8Z</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>Royal York South West\n",
"</td></tr>\n",
"<tr>\n",
"<td>M8Z</td>\n",
"<td><a href=\"/wiki/Etobicoke\" title=\"Etobicoke\">Etobicoke</a></td>\n",
"<td>South of Bloor\n",
"</td></tr>\n",
"<tr>\n",
"<td>M9Z</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>\n",
"</tbody></table>"
]
},
"execution_count": 143,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#soup.find_all(class_= \"wikitable sortable\") #extracting table from the web page contents\n",
"table = soup.find(class_=\"wikitable sortable\")\n",
"table"
]
},
{
"cell_type": "code",
"execution_count": 144,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[<tr>\n",
"<th>Postcode</th>\n",
"<th>Borough</th>\n",
"<th>Neighbourhood\n",
"</th></tr>, <tr>\n",
"<td>M1A</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>, <tr>\n",
"<td>M2A</td>\n",
"<td>Not assigned</td>\n",
"<td>Not assigned\n",
"</td></tr>, <tr>\n",
"<td>M3A</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Parkwoods\" title=\"Parkwoods\">Parkwoods</a>\n",
"</td></tr>, <tr>\n",
"<td>M4A</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Victoria_Village\" title=\"Victoria Village\">Victoria Village</a>\n",
"</td></tr>, <tr>\n",
"<td>M5A</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/Harbourfront_(Toronto)\" title=\"Harbourfront (Toronto)\">Harbourfront</a>\n",
"</td></tr>, <tr>\n",
"<td>M5A</td>\n",
"<td><a href=\"/wiki/Downtown_Toronto\" title=\"Downtown Toronto\">Downtown Toronto</a></td>\n",
"<td><a href=\"/wiki/Regent_Park\" title=\"Regent Park\">Regent Park</a>\n",
"</td></tr>, <tr>\n",
"<td>M6A</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Lawrence_Heights\" title=\"Lawrence Heights\">Lawrence Heights</a>\n",
"</td></tr>, <tr>\n",
"<td>M6A</td>\n",
"<td><a href=\"/wiki/North_York\" title=\"North York\">North York</a></td>\n",
"<td><a href=\"/wiki/Lawrence_Manor\" title=\"Lawrence Manor\">Lawrence Manor</a>\n",
"</td></tr>, <tr>\n",
"<td>M7A</td>\n",
"<td><a href=\"/wiki/Queen%27s_Park_(Toronto)\" title=\"Queen's Park (Toronto)\">Queen's Park</a></td>\n",
"<td>Not assigned\n",
"</td></tr>]\n"
]
}
],
"source": [
"rows = soup.find_all('tr')\n",
"print(rows[:10])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<b>Step2 : We will now transfer the data from the HTML table into a lsit</b>"
]
},
{
"cell_type": "code",
"execution_count": 145,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['M1A',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M2A',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M3A',\n",
" 'North York',\n",
" 'Parkwoods\\n',\n",
" 'M4A',\n",
" 'North York',\n",
" 'Victoria Village\\n',\n",
" 'M5A',\n",
" 'Downtown Toronto',\n",
" 'Harbourfront\\n',\n",
" 'M5A',\n",
" 'Downtown Toronto',\n",
" 'Regent Park\\n',\n",
" 'M6A',\n",
" 'North York',\n",
" 'Lawrence Heights\\n',\n",
" 'M6A',\n",
" 'North York',\n",
" 'Lawrence Manor\\n',\n",
" 'M7A',\n",
" \"Queen's Park\",\n",
" 'Not assigned\\n',\n",
" 'M8A',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M9A',\n",
" 'Etobicoke',\n",
" 'Islington Avenue\\n',\n",
" 'M1B',\n",
" 'Scarborough',\n",
" 'Rouge\\n',\n",
" 'M1B',\n",
" 'Scarborough',\n",
" 'Malvern\\n',\n",
" 'M2B',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M3B',\n",
" 'North York',\n",
" 'Don Mills North\\n',\n",
" 'M4B',\n",
" 'East York',\n",
" 'Woodbine Gardens\\n',\n",
" 'M4B',\n",
" 'East York',\n",
" 'Parkview Hill\\n',\n",
" 'M5B',\n",
" 'Downtown Toronto',\n",
" 'Ryerson\\n',\n",
" 'M5B',\n",
" 'Downtown Toronto',\n",
" 'Garden District\\n',\n",
" 'M6B',\n",
" 'North York',\n",
" 'Glencairn\\n',\n",
" 'M7B',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M8B',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M9B',\n",
" 'Etobicoke',\n",
" 'Cloverdale\\n',\n",
" 'M9B',\n",
" 'Etobicoke',\n",
" 'Islington\\n',\n",
" 'M9B',\n",
" 'Etobicoke',\n",
" 'Martin Grove\\n',\n",
" 'M9B',\n",
" 'Etobicoke',\n",
" 'Princess Gardens\\n',\n",
" 'M9B',\n",
" 'Etobicoke',\n",
" 'West Deane Park\\n',\n",
" 'M1C',\n",
" 'Scarborough',\n",
" 'Highland Creek\\n',\n",
" 'M1C',\n",
" 'Scarborough',\n",
" 'Rouge Hill\\n',\n",
" 'M1C',\n",
" 'Scarborough',\n",
" 'Port Union\\n',\n",
" 'M2C',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M3C',\n",
" 'North York',\n",
" 'Flemingdon Park\\n',\n",
" 'M3C',\n",
" 'North York',\n",
" 'Don Mills South\\n',\n",
" 'M4C',\n",
" 'East York',\n",
" 'Woodbine Heights\\n',\n",
" 'M5C',\n",
" 'Downtown Toronto',\n",
" 'St. James Town\\n',\n",
" 'M6C',\n",
" 'York',\n",
" 'Humewood-Cedarvale\\n',\n",
" 'M7C',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M8C',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M9C',\n",
" 'Etobicoke',\n",
" 'Bloordale Gardens\\n',\n",
" 'M9C',\n",
" 'Etobicoke',\n",
" 'Eringate\\n',\n",
" 'M9C',\n",
" 'Etobicoke',\n",
" 'Markland Wood\\n',\n",
" 'M9C',\n",
" 'Etobicoke',\n",
" 'Old Burnhamthorpe\\n',\n",
" 'M1E',\n",
" 'Scarborough',\n",
" 'Guildwood\\n',\n",
" 'M1E',\n",
" 'Scarborough',\n",
" 'Morningside\\n',\n",
" 'M1E',\n",
" 'Scarborough',\n",
" 'West Hill\\n',\n",
" 'M2E',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M3E',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M4E',\n",
" 'East Toronto',\n",
" 'The Beaches\\n',\n",
" 'M5E',\n",
" 'Downtown Toronto',\n",
" 'Berczy Park\\n',\n",
" 'M6E',\n",
" 'York',\n",
" 'Caledonia-Fairbanks\\n',\n",
" 'M7E',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M8E',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M9E',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M1G',\n",
" 'Scarborough',\n",
" 'Woburn\\n',\n",
" 'M2G',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M3G',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M4G',\n",
" 'East York',\n",
" 'Leaside\\n',\n",
" 'M5G',\n",
" 'Downtown Toronto',\n",
" 'Central Bay Street\\n',\n",
" 'M6G',\n",
" 'Downtown Toronto',\n",
" 'Christie\\n',\n",
" 'M7G',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M8G',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M9G',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M1H',\n",
" 'Scarborough',\n",
" 'Cedarbrae\\n',\n",
" 'M2H',\n",
" 'North York',\n",
" 'Hillcrest Village\\n',\n",
" 'M3H',\n",
" 'North York',\n",
" 'Bathurst Manor\\n',\n",
" 'M3H',\n",
" 'North York',\n",
" 'Downsview North\\n',\n",
" 'M3H',\n",
" 'North York',\n",
" 'Wilson Heights\\n',\n",
" 'M4H',\n",
" 'East York',\n",
" 'Thorncliffe Park\\n',\n",
" 'M5H',\n",
" 'Downtown Toronto',\n",
" 'Adelaide\\n',\n",
" 'M5H',\n",
" 'Downtown Toronto',\n",
" 'King\\n',\n",
" 'M5H',\n",
" 'Downtown Toronto',\n",
" 'Richmond\\n',\n",
" 'M6H',\n",
" 'West Toronto',\n",
" 'Dovercourt Village\\n',\n",
" 'M6H',\n",
" 'West Toronto',\n",
" 'Dufferin\\n',\n",
" 'M7H',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M8H',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M9H',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M1J',\n",
" 'Scarborough',\n",
" 'Scarborough Village\\n',\n",
" 'M2J',\n",
" 'North York',\n",
" 'Fairview\\n',\n",
" 'M2J',\n",
" 'North York',\n",
" 'Henry Farm\\n',\n",
" 'M2J',\n",
" 'North York',\n",
" 'Oriole\\n',\n",
" 'M3J',\n",
" 'North York',\n",
" 'Northwood Park\\n',\n",
" 'M3J',\n",
" 'North York',\n",
" 'York University\\n',\n",
" 'M4J',\n",
" 'East York',\n",
" 'East Toronto\\n',\n",
" 'M5J',\n",
" 'Downtown Toronto',\n",
" 'Harbourfront East\\n',\n",
" 'M5J',\n",
" 'Downtown Toronto',\n",
" 'Toronto Islands\\n',\n",
" 'M5J',\n",
" 'Downtown Toronto',\n",
" 'Union Station\\n',\n",
" 'M6J',\n",
" 'West Toronto',\n",
" 'Little Portugal\\n',\n",
" 'M6J',\n",
" 'West Toronto',\n",
" 'Trinity\\n',\n",
" 'M7J',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M8J',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M9J',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M1K',\n",
" 'Scarborough',\n",
" 'East Birchmount Park\\n',\n",
" 'M1K',\n",
" 'Scarborough',\n",
" 'Ionview\\n',\n",
" 'M1K',\n",
" 'Scarborough',\n",
" 'Kennedy Park\\n',\n",
" 'M2K',\n",
" 'North York',\n",
" 'Bayview Village\\n',\n",
" 'M3K',\n",
" 'North York',\n",
" 'CFB Toronto\\n',\n",
" 'M3K',\n",
" 'North York',\n",
" 'Downsview East\\n',\n",
" 'M4K',\n",
" 'East Toronto',\n",
" 'The Danforth West\\n',\n",
" 'M4K',\n",
" 'East Toronto',\n",
" 'Riverdale\\n',\n",
" 'M5K',\n",
" 'Downtown Toronto',\n",
" 'Design Exchange\\n',\n",
" 'M5K',\n",
" 'Downtown Toronto',\n",
" 'Toronto Dominion Centre\\n',\n",
" 'M6K',\n",
" 'West Toronto',\n",
" 'Brockton\\n',\n",
" 'M6K',\n",
" 'West Toronto',\n",
" 'Exhibition Place\\n',\n",
" 'M6K',\n",
" 'West Toronto',\n",
" 'Parkdale Village\\n',\n",
" 'M7K',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M8K',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M9K',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M1L',\n",
" 'Scarborough',\n",
" 'Clairlea\\n',\n",
" 'M1L',\n",
" 'Scarborough',\n",
" 'Golden Mile\\n',\n",
" 'M1L',\n",
" 'Scarborough',\n",
" 'Oakridge\\n',\n",
" 'M2L',\n",
" 'North York',\n",
" 'Silver Hills\\n',\n",
" 'M2L',\n",
" 'North York',\n",
" 'York Mills\\n',\n",
" 'M3L',\n",
" 'North York',\n",
" 'Downsview West\\n',\n",
" 'M4L',\n",
" 'East Toronto',\n",
" 'The Beaches West\\n',\n",
" 'M4L',\n",
" 'East Toronto',\n",
" 'India Bazaar\\n',\n",
" 'M5L',\n",
" 'Downtown Toronto',\n",
" 'Commerce Court\\n',\n",
" 'M5L',\n",
" 'Downtown Toronto',\n",
" 'Victoria Hotel\\n',\n",
" 'M6L',\n",
" 'North York',\n",
" 'Downsview\\n',\n",
" 'M6L',\n",
" 'North York',\n",
" 'North Park\\n',\n",
" 'M6L',\n",
" 'North York',\n",
" 'Upwood Park\\n',\n",
" 'M7L',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M8L',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M9L',\n",
" 'North York',\n",
" 'Humber Summit\\n',\n",
" 'M1M',\n",
" 'Scarborough',\n",
" 'Cliffcrest\\n',\n",
" 'M1M',\n",
" 'Scarborough',\n",
" 'Cliffside\\n',\n",
" 'M1M',\n",
" 'Scarborough',\n",
" 'Scarborough Village West\\n',\n",
" 'M2M',\n",
" 'North York',\n",
" 'Newtonbrook\\n',\n",
" 'M2M',\n",
" 'North York',\n",
" 'Willowdale\\n',\n",
" 'M3M',\n",
" 'North York',\n",
" 'Downsview Central\\n',\n",
" 'M4M',\n",
" 'East Toronto',\n",
" 'Studio District\\n',\n",
" 'M5M',\n",
" 'North York',\n",
" 'Bedford Park\\n',\n",
" 'M5M',\n",
" 'North York',\n",
" 'Lawrence Manor East\\n',\n",
" 'M6M',\n",
" 'York',\n",
" 'Del Ray\\n',\n",
" 'M6M',\n",
" 'York',\n",
" 'Keelesdale\\n',\n",
" 'M6M',\n",
" 'York',\n",
" 'Mount Dennis\\n',\n",
" 'M6M',\n",
" 'York',\n",
" 'Silverthorn\\n',\n",
" 'M7M',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M8M',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M9M',\n",
" 'North York',\n",
" 'Emery\\n',\n",
" 'M9M',\n",
" 'North York',\n",
" 'Humberlea\\n',\n",
" 'M1N',\n",
" 'Scarborough',\n",
" 'Birch Cliff\\n',\n",
" 'M1N',\n",
" 'Scarborough',\n",
" 'Cliffside West\\n',\n",
" 'M2N',\n",
" 'North York',\n",
" 'Willowdale South\\n',\n",
" 'M3N',\n",
" 'North York',\n",
" 'Downsview Northwest\\n',\n",
" 'M4N',\n",
" 'Central Toronto',\n",
" 'Lawrence Park\\n',\n",
" 'M5N',\n",
" 'Central Toronto',\n",
" 'Roselawn\\n',\n",
" 'M6N',\n",
" 'York',\n",
" 'The Junction North\\n',\n",
" 'M6N',\n",
" 'York',\n",
" 'Runnymede\\n',\n",
" 'M7N',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M8N',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M9N',\n",
" 'York',\n",
" 'Weston\\n',\n",
" 'M1P',\n",
" 'Scarborough',\n",
" 'Dorset Park\\n',\n",
" 'M1P',\n",
" 'Scarborough',\n",
" 'Scarborough Town Centre\\n',\n",
" 'M1P',\n",
" 'Scarborough',\n",
" 'Wexford Heights\\n',\n",
" 'M2P',\n",
" 'North York',\n",
" 'York Mills West\\n',\n",
" 'M3P',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M4P',\n",
" 'Central Toronto',\n",
" 'Davisville North\\n',\n",
" 'M5P',\n",
" 'Central Toronto',\n",
" 'Forest Hill North\\n',\n",
" 'M5P',\n",
" 'Central Toronto',\n",
" 'Forest Hill West\\n',\n",
" 'M6P',\n",
" 'West Toronto',\n",
" 'High Park\\n',\n",
" 'M6P',\n",
" 'West Toronto',\n",
" 'The Junction South\\n',\n",
" 'M7P',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M8P',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M9P',\n",
" 'Etobicoke',\n",
" 'Westmount\\n',\n",
" 'M1R',\n",
" 'Scarborough',\n",
" 'Maryvale\\n',\n",
" 'M1R',\n",
" 'Scarborough',\n",
" 'Wexford\\n',\n",
" 'M2R',\n",
" 'North York',\n",
" 'Willowdale West\\n',\n",
" 'M3R',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M4R',\n",
" 'Central Toronto',\n",
" 'North Toronto West\\n',\n",
" 'M5R',\n",
" 'Central Toronto',\n",
" 'The Annex\\n',\n",
" 'M5R',\n",
" 'Central Toronto',\n",
" 'North Midtown\\n',\n",
" 'M5R',\n",
" 'Central Toronto',\n",
" 'Yorkville\\n',\n",
" 'M6R',\n",
" 'West Toronto',\n",
" 'Parkdale\\n',\n",
" 'M6R',\n",
" 'West Toronto',\n",
" 'Roncesvalles\\n',\n",
" 'M7R',\n",
" 'Mississauga',\n",
" 'Canada Post Gateway Processing Centre\\n',\n",
" 'M8R',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M9R',\n",
" 'Etobicoke',\n",
" 'Kingsview Village\\n',\n",
" 'M9R',\n",
" 'Etobicoke',\n",
" 'Martin Grove Gardens\\n',\n",
" 'M9R',\n",
" 'Etobicoke',\n",
" 'Richview Gardens\\n',\n",
" 'M9R',\n",
" 'Etobicoke',\n",
" 'St. Phillips\\n',\n",
" 'M1S',\n",
" 'Scarborough',\n",
" 'Agincourt\\n',\n",
" 'M2S',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M3S',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M4S',\n",
" 'Central Toronto',\n",
" 'Davisville\\n',\n",
" 'M5S',\n",
" 'Downtown Toronto',\n",
" 'Harbord\\n',\n",
" 'M5S',\n",
" 'Downtown Toronto',\n",
" 'University of Toronto\\n',\n",
" 'M6S',\n",
" 'West Toronto',\n",
" 'Runnymede\\n',\n",
" 'M6S',\n",
" 'West Toronto',\n",
" 'Swansea\\n',\n",
" 'M7S',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M8S',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M9S',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M1T',\n",
" 'Scarborough',\n",
" 'Clarks Corners\\n',\n",
" 'M1T',\n",
" 'Scarborough',\n",
" 'Sullivan\\n',\n",
" 'M1T',\n",
" 'Scarborough',\n",
" \"Tam O'Shanter\\n\",\n",
" 'M2T',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M3T',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M4T',\n",
" 'Central Toronto',\n",
" 'Moore Park\\n',\n",
" 'M4T',\n",
" 'Central Toronto',\n",
" 'Summerhill East\\n',\n",
" 'M5T',\n",
" 'Downtown Toronto',\n",
" 'Chinatown\\n',\n",
" 'M5T',\n",
" 'Downtown Toronto',\n",
" 'Grange Park\\n',\n",
" 'M5T',\n",
" 'Downtown Toronto',\n",
" 'Kensington Market\\n',\n",
" 'M6T',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M7T',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M8T',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M9T',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M1V',\n",
" 'Scarborough',\n",
" 'Agincourt North\\n',\n",
" 'M1V',\n",
" 'Scarborough',\n",
" \"L'Amoreaux East\\n\",\n",
" 'M1V',\n",
" 'Scarborough',\n",
" 'Milliken\\n',\n",
" 'M1V',\n",
" 'Scarborough',\n",
" 'Steeles East\\n',\n",
" 'M2V',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M3V',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M4V',\n",
" 'Central Toronto',\n",
" 'Deer Park\\n',\n",
" 'M4V',\n",
" 'Central Toronto',\n",
" 'Forest Hill SE\\n',\n",
" 'M4V',\n",
" 'Central Toronto',\n",
" 'Rathnelly\\n',\n",
" 'M4V',\n",
" 'Central Toronto',\n",
" 'South Hill\\n',\n",
" 'M4V',\n",
" 'Central Toronto',\n",
" 'Summerhill West\\n',\n",
" 'M5V',\n",
" 'Downtown Toronto',\n",
" 'CN Tower\\n',\n",
" 'M5V',\n",
" 'Downtown Toronto',\n",
" 'Bathurst Quay\\n',\n",
" 'M5V',\n",
" 'Downtown Toronto',\n",
" 'Island airport\\n',\n",
" 'M5V',\n",
" 'Downtown Toronto',\n",
" 'Harbourfront West\\n',\n",
" 'M5V',\n",
" 'Downtown Toronto',\n",
" 'King and Spadina\\n',\n",
" 'M5V',\n",
" 'Downtown Toronto',\n",
" 'Railway Lands\\n',\n",
" 'M5V',\n",
" 'Downtown Toronto',\n",
" 'South Niagara\\n',\n",
" 'M6V',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M7V',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M8V',\n",
" 'Etobicoke',\n",
" 'Humber Bay Shores\\n',\n",
" 'M8V',\n",
" 'Etobicoke',\n",
" 'Mimico South\\n',\n",
" 'M8V',\n",
" 'Etobicoke',\n",
" 'New Toronto\\n',\n",
" 'M9V',\n",
" 'Etobicoke',\n",
" 'Albion Gardens\\n',\n",
" 'M9V',\n",
" 'Etobicoke',\n",
" 'Beaumond Heights\\n',\n",
" 'M9V',\n",
" 'Etobicoke',\n",
" 'Humbergate\\n',\n",
" 'M9V',\n",
" 'Etobicoke',\n",
" 'Jamestown\\n',\n",
" 'M9V',\n",
" 'Etobicoke',\n",
" 'Mount Olive\\n',\n",
" 'M9V',\n",
" 'Etobicoke',\n",
" 'Silverstone\\n',\n",
" 'M9V',\n",
" 'Etobicoke',\n",
" 'South Steeles\\n',\n",
" 'M9V',\n",
" 'Etobicoke',\n",
" 'Thistletown\\n',\n",
" 'M1W',\n",
" 'Scarborough',\n",
" \"L'Amoreaux West\\n\",\n",
" 'M2W',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M3W',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M4W',\n",
" 'Downtown Toronto',\n",
" 'Rosedale\\n',\n",
" 'M5W',\n",
" 'Downtown Toronto',\n",
" 'Stn A PO Boxes 25 The Esplanade\\n',\n",
" 'M6W',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M7W',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M8W',\n",
" 'Etobicoke',\n",
" 'Alderwood\\n',\n",
" 'M8W',\n",
" 'Etobicoke',\n",
" 'Long Branch\\n',\n",
" 'M9W',\n",
" 'Etobicoke',\n",
" 'Northwest\\n',\n",
" 'M1X',\n",
" 'Scarborough',\n",
" 'Upper Rouge\\n',\n",
" 'M2X',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M3X',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M4X',\n",
" 'Downtown Toronto',\n",
" 'Cabbagetown\\n',\n",
" 'M4X',\n",
" 'Downtown Toronto',\n",
" 'St. James Town\\n',\n",
" 'M5X',\n",
" 'Downtown Toronto',\n",
" 'First Canadian Place\\n',\n",
" 'M5X',\n",
" 'Downtown Toronto',\n",
" 'Underground city\\n',\n",
" 'M6X',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M7X',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M8X',\n",
" 'Etobicoke',\n",
" 'The Kingsway\\n',\n",
" 'M8X',\n",
" 'Etobicoke',\n",
" 'Montgomery Road\\n',\n",
" 'M8X',\n",
" 'Etobicoke',\n",
" 'Old Mill North\\n',\n",
" 'M9X',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M1Y',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M2Y',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M3Y',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M4Y',\n",
" 'Downtown Toronto',\n",
" 'Church and Wellesley\\n',\n",
" 'M5Y',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M6Y',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M7Y',\n",
" 'East Toronto',\n",
" 'Business Reply Mail Processing Centre 969 Eastern\\n',\n",
" 'M8Y',\n",
" 'Etobicoke',\n",
" 'Humber Bay\\n',\n",
" 'M8Y',\n",
" 'Etobicoke',\n",
" \"King's Mill Park\\n\",\n",
" 'M8Y',\n",
" 'Etobicoke',\n",
" 'Kingsway Park South East\\n',\n",
" 'M8Y',\n",
" 'Etobicoke',\n",
" 'Mimico NE\\n',\n",
" 'M8Y',\n",
" 'Etobicoke',\n",
" 'Old Mill South\\n',\n",
" 'M8Y',\n",
" 'Etobicoke',\n",
" 'The Queensway East\\n',\n",
" 'M8Y',\n",
" 'Etobicoke',\n",
" 'Royal York South East\\n',\n",
" 'M8Y',\n",
" 'Etobicoke',\n",
" 'Sunnylea\\n',\n",
" 'M9Y',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M1Z',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M2Z',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M3Z',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M4Z',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M5Z',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M6Z',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M7Z',\n",
" 'Not assigned',\n",
" 'Not assigned\\n',\n",
" 'M8Z',\n",
" 'Etobicoke',\n",
" 'Kingsway Park South West\\n',\n",
" 'M8Z',\n",
" 'Etobicoke',\n",
" 'Mimico NW\\n',\n",
" 'M8Z',\n",
" 'Etobicoke',\n",
" 'The Queensway West\\n',\n",
" 'M8Z',\n",
" 'Etobicoke',\n",
" 'Royal York South West\\n',\n",
" 'M8Z',\n",
" 'Etobicoke',\n",
" 'South of Bloor\\n',\n",
" 'M9Z',\n",
" 'Not assigned',\n",
" 'Not assigned\\n']"
]
},
"execution_count": 145,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#extracting the contents from the HTML table into a list\n",
"table_text=[]\n",
"for tr in table.findAll('tr'):\n",
" tds = tr.findAll('td')\n",
" for td in tds:\n",
" table_text.append(td.get_text()) \n",
"table_text"
]
},
{
"cell_type": "code",
"execution_count": 146,
"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>Postcode</th>\n",
" <th>Borough</th>\n",
" <th>Neighborhood</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <td>0</td>\n",
" <td>M1A</td>\n",
" <td>Not assigned</td>\n",
" <td>Not assigned\\n</td>\n",
" </tr>\n",
" <tr>\n",
" <td>1</td>\n",
" <td>M2A</td>\n",
" <td>Not assigned</td>\n",
" <td>Not assigned\\n</td>\n",
" </tr>\n",
" <tr>\n",
" <td>2</td>\n",
" <td>M3A</td>\n",
" <td>North York</td>\n",
" <td>Parkwoods\\n</td>\n",
" </tr>\n",
" <tr>\n",
" <td>3</td>\n",
" <td>M4A</td>\n",
" <td>North York</td>\n",
" <td>Victoria Village\\n</td>\n",
" </tr>\n",
" <tr>\n",
" <td>4</td>\n",
" <td>M5A</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Harbourfront\\n</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Postcode Borough Neighborhood\n",
"0 M1A Not assigned Not assigned\\n\n",
"1 M2A Not assigned Not assigned\\n\n",
"2 M3A North York Parkwoods\\n\n",
"3 M4A North York Victoria Village\\n\n",
"4 M5A Downtown Toronto Harbourfront\\n"
]
},
"execution_count": 146,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#formating the data from the list into a dataframe\n",
"def divide_chunks(l, n): \n",
" \n",
" # looping till length l \n",
" for i in range(0, len(l), n): \n",
" yield l[i:i + n] \n",
" \n",
"# How many elements each \n",
"# list should have \n",
"n = 3\n",
" \n",
"x = list(divide_chunks(table_text, n)) \n",
"#print (x) \n",
"\n",
"df = pd.DataFrame(x, columns =['Postcode', 'Borough','Neighborhood'])\n",
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<b>Step 3: Here we go for data wrangling and cleaning once we get the data in a dataframe</b>"
]
},
{
"cell_type": "code",
"execution_count": 147,
"metadata": {},
"outputs": [],
"source": [
"#data wrangling\n",
"df['Neighborhood'] = df['Neighborhood'].map(lambda x: str(x)[:-1])"
]
},
{
"cell_type": "code",
"execution_count": 148,
"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>Postcode</th>\n",
" <th>Borough</th>\n",
" <th>Neighborhood</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <td>2</td>\n",
" <td>M3A</td>\n",
" <td>North York</td>\n",
" <td>Parkwoods</td>\n",
" </tr>\n",
" <tr>\n",
" <td>3</td>\n",
" <td>M4A</td>\n",
" <td>North York</td>\n",
" <td>Victoria Village</td>\n",
" </tr>\n",
" <tr>\n",
" <td>4</td>\n",
" <td>M5A</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Harbourfront</td>\n",
" </tr>\n",
" <tr>\n",
" <td>5</td>\n",
" <td>M5A</td>\n",
" <td>Downtown Toronto</td>\n",
" <td>Regent Park</td>\n",
" </tr>\n",
" <tr>\n",
" <td>6</td>\n",
" <td>M6A</td>\n",
" <td>North York</td>\n",
" <td>Lawrence Heights</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Postcode Borough Neighborhood\n",
"2 M3A North York Parkwoods\n",
"3 M4A North York Victoria Village\n",
"4 M5A Downtown Toronto Harbourfront\n",
"5 M5A Downtown Toronto Regent Park\n",
"6 M6A North York Lawrence Heights"
]
},
"execution_count": 148,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = df[df.Neighborhood != 'Not assigned']\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 149,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(210, 3)"
]
},
"execution_count": 149,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python",
"language": "python",
"name": "conda-env-python-py"
},
"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.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment