Skip to content

Instantly share code, notes, and snippets.

@ruxi
Created March 3, 2018 22:52
Show Gist options
  • Save ruxi/5d3b56e60a609d52d79b700e49fd9fcf to your computer and use it in GitHub Desktop.
Save ruxi/5d3b56e60a609d52d79b700e49fd9fcf to your computer and use it in GitHub Desktop.
opendata hackathon 2018 (rough draft)
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- https://data.winnipeg.ca/Recreation/Pool-Facility-Usage/j4s8-s9ap\n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:05.274240Z",
"start_time": "2018-03-03T22:49:05.269528Z"
}
},
"outputs": [],
"source": [
"#!pip install sodapy"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:05.686883Z",
"start_time": "2018-03-03T22:49:05.277887Z"
}
},
"outputs": [],
"source": [
"import pandas as pd\n",
"from sodapy import Socrata"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:06.217582Z",
"start_time": "2018-03-03T22:49:05.689848Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:root:Requests made without an app_token will be subject to strict throttling limits.\n"
]
}
],
"source": [
"client = Socrata(\"data.winnipeg.ca\", None)\n",
"results = client.get(\"t2d2-j4v9\", limit=2000)\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:06.231800Z",
"start_time": "2018-03-03T22:49:06.220507Z"
}
},
"outputs": [],
"source": [
"df = pd.DataFrame.from_records(results)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:06.249445Z",
"start_time": "2018-03-03T22:49:06.234000Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"Index(['activity_category', 'activity_name', 'activity_number',\n",
" 'activity_status', 'activity_type', 'attendance', 'center',\n",
" 'customer_type', 'end_date', 'end_time', 'event_type', 'item_name',\n",
" 'item_type', 'schedule_type', 'secondary_category', 'start_date',\n",
" 'start_time'],\n",
" dtype='object')"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.columns"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:06.273564Z",
"start_time": "2018-03-03T22:49:06.251690Z"
}
},
"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>0</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" <th>3</th>\n",
" <th>4</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>activity_category</th>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Preschool - Birth to 5 years</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>activity_name</th>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Kinder Ballet Level I 3-5 years</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>activity_number</th>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>6259</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>activity_status</th>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Closed</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>activity_type</th>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Activity</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>attendance</th>\n",
" <td>30</td>\n",
" <td>15</td>\n",
" <td>30</td>\n",
" <td>11</td>\n",
" <td>6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>center</th>\n",
" <td>Pan Am Pool</td>\n",
" <td>Cindy Klassen Recreation Complex</td>\n",
" <td>Pan Am Pool</td>\n",
" <td>Pan Am Pool</td>\n",
" <td>Pan Am Pool</td>\n",
" </tr>\n",
" <tr>\n",
" <th>customer_type</th>\n",
" <td>Authorized Agent</td>\n",
" <td>Authorized Agent</td>\n",
" <td>Authorized Agent</td>\n",
" <td>NaN</td>\n",
" <td>General Public</td>\n",
" </tr>\n",
" <tr>\n",
" <th>end_date</th>\n",
" <td>2016-01-19T00:00:00.000</td>\n",
" <td>2016-01-30T00:00:00.000</td>\n",
" <td>2016-01-22T00:00:00.000</td>\n",
" <td>2016-02-20T00:00:00.000</td>\n",
" <td>2016-03-05T00:00:00.000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>end_time</th>\n",
" <td>8:00 PM</td>\n",
" <td>8:30 AM</td>\n",
" <td>7:30 AM</td>\n",
" <td>9:45 AM</td>\n",
" <td>11:30 AM</td>\n",
" </tr>\n",
" <tr>\n",
" <th>event_type</th>\n",
" <td>Aquatics - Contract User</td>\n",
" <td>Aquatics - Contract User</td>\n",
" <td>Aquatics - Contract User</td>\n",
" <td>NaN</td>\n",
" <td>Aquatics - Contract User</td>\n",
" </tr>\n",
" <tr>\n",
" <th>item_name</th>\n",
" <td>PAP - Middle - Lane 6</td>\n",
" <td>CKRC - Middle - Lane 7</td>\n",
" <td>PAP - Middle - Lane 10</td>\n",
" <td>PAP - Kiddie Pool - Area 1</td>\n",
" <td>PAP - Training - North - Lane 1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>item_type</th>\n",
" <td>Pool - Indoor</td>\n",
" <td>Pool - Indoor</td>\n",
" <td>Pool - Indoor</td>\n",
" <td>Pool - Indoor</td>\n",
" <td>Pool - Indoor</td>\n",
" </tr>\n",
" <tr>\n",
" <th>schedule_type</th>\n",
" <td>External Reservation</td>\n",
" <td>External Reservation</td>\n",
" <td>External Reservation</td>\n",
" <td>Standard Activity</td>\n",
" <td>External Reservation</td>\n",
" </tr>\n",
" <tr>\n",
" <th>secondary_category</th>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Movement/Fitness</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>start_date</th>\n",
" <td>2016-01-19T00:00:00.000</td>\n",
" <td>2016-01-30T00:00:00.000</td>\n",
" <td>2016-01-22T00:00:00.000</td>\n",
" <td>2016-02-20T00:00:00.000</td>\n",
" <td>2016-03-05T00:00:00.000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>start_time</th>\n",
" <td>5:00 PM</td>\n",
" <td>7:30 AM</td>\n",
" <td>5:45 AM</td>\n",
" <td>9:00 AM</td>\n",
" <td>10:00 AM</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0 \\\n",
"activity_category NaN \n",
"activity_name NaN \n",
"activity_number NaN \n",
"activity_status NaN \n",
"activity_type NaN \n",
"attendance 30 \n",
"center Pan Am Pool \n",
"customer_type Authorized Agent \n",
"end_date 2016-01-19T00:00:00.000 \n",
"end_time 8:00 PM \n",
"event_type Aquatics - Contract User \n",
"item_name PAP - Middle - Lane 6 \n",
"item_type Pool - Indoor \n",
"schedule_type External Reservation \n",
"secondary_category NaN \n",
"start_date 2016-01-19T00:00:00.000 \n",
"start_time 5:00 PM \n",
"\n",
" 1 \\\n",
"activity_category NaN \n",
"activity_name NaN \n",
"activity_number NaN \n",
"activity_status NaN \n",
"activity_type NaN \n",
"attendance 15 \n",
"center Cindy Klassen Recreation Complex \n",
"customer_type Authorized Agent \n",
"end_date 2016-01-30T00:00:00.000 \n",
"end_time 8:30 AM \n",
"event_type Aquatics - Contract User \n",
"item_name CKRC - Middle - Lane 7 \n",
"item_type Pool - Indoor \n",
"schedule_type External Reservation \n",
"secondary_category NaN \n",
"start_date 2016-01-30T00:00:00.000 \n",
"start_time 7:30 AM \n",
"\n",
" 2 3 \\\n",
"activity_category NaN Preschool - Birth to 5 years \n",
"activity_name NaN Kinder Ballet Level I 3-5 years \n",
"activity_number NaN 6259 \n",
"activity_status NaN Closed \n",
"activity_type NaN Activity \n",
"attendance 30 11 \n",
"center Pan Am Pool Pan Am Pool \n",
"customer_type Authorized Agent NaN \n",
"end_date 2016-01-22T00:00:00.000 2016-02-20T00:00:00.000 \n",
"end_time 7:30 AM 9:45 AM \n",
"event_type Aquatics - Contract User NaN \n",
"item_name PAP - Middle - Lane 10 PAP - Kiddie Pool - Area 1 \n",
"item_type Pool - Indoor Pool - Indoor \n",
"schedule_type External Reservation Standard Activity \n",
"secondary_category NaN Movement/Fitness \n",
"start_date 2016-01-22T00:00:00.000 2016-02-20T00:00:00.000 \n",
"start_time 5:45 AM 9:00 AM \n",
"\n",
" 4 \n",
"activity_category NaN \n",
"activity_name NaN \n",
"activity_number NaN \n",
"activity_status NaN \n",
"activity_type NaN \n",
"attendance 6 \n",
"center Pan Am Pool \n",
"customer_type General Public \n",
"end_date 2016-03-05T00:00:00.000 \n",
"end_time 11:30 AM \n",
"event_type Aquatics - Contract User \n",
"item_name PAP - Training - North - Lane 1 \n",
"item_type Pool - Indoor \n",
"schedule_type External Reservation \n",
"secondary_category NaN \n",
"start_date 2016-03-05T00:00:00.000 \n",
"start_time 10:00 AM "
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head().T"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:06.605440Z",
"start_time": "2018-03-03T22:49:06.275730Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:root:Requests made without an app_token will be subject to strict throttling limits.\n"
]
}
],
"source": [
"client = Socrata(\"data.winnipeg.ca\", None)\n",
"bugs = client.get(\"du7c-8488\", limit=2000)\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:06.621642Z",
"start_time": "2018-03-03T22:49:06.608311Z"
}
},
"outputs": [],
"source": [
"bugsdf = pd.DataFrame(bugs)\n",
"bugsdf.T\n",
"idvars = ['count_date', 'trap_days']"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:06.645020Z",
"start_time": "2018-03-03T22:49:06.634085Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"37"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"idvars = ['count_date', 'trap_days']\n",
"location_only = [x for x in bugsdf.columns if \"average\" not in x]\n",
"location_only = [x for x in location_only if x not in idvars]\n",
"len(location_only)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:06.763449Z",
"start_time": "2018-03-03T22:49:06.648087Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Datasets.ipynb\tDatasets_v2.ipynb environment.yml\r\n"
]
}
],
"source": [
"!ls "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"hello world"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:06.776469Z",
"start_time": "2018-03-03T22:49:06.765589Z"
}
},
"outputs": [],
"source": [
"bugcleaned = pd.melt(bugsdf[location_only + idvars], id_vars = idvars, var_name = 'location', value_name = 'bugcount')"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:07.235648Z",
"start_time": "2018-03-03T22:49:06.779903Z"
}
},
"outputs": [],
"source": [
"import seaborn as sns\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:13:32.163458Z",
"start_time": "2018-03-03T22:13:32.060247Z"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:07.511118Z",
"start_time": "2018-03-03T22:49:07.238249Z"
}
},
"outputs": [],
"source": [
"parkbikedata = \"9t9k-ya8b\"\n",
"parkbikedf = client.get(\"9t9k-ya8b\", limit=2000)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:07.578104Z",
"start_time": "2018-03-03T22:49:07.513702Z"
}
},
"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>0</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" <th>3</th>\n",
" <th>4</th>\n",
" <th>5</th>\n",
" <th>6</th>\n",
" <th>7</th>\n",
" <th>8</th>\n",
" <th>9</th>\n",
" <th>...</th>\n",
" <th>1990</th>\n",
" <th>1991</th>\n",
" <th>1992</th>\n",
" <th>1993</th>\n",
" <th>1994</th>\n",
" <th>1995</th>\n",
" <th>1996</th>\n",
" <th>1997</th>\n",
" <th>1998</th>\n",
" <th>1999</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>asset_class</th>\n",
" <td>STAND-ALONE PLAY COMPONENT</td>\n",
" <td>SEATING</td>\n",
" <td>SEATING</td>\n",
" <td>SEATING</td>\n",
" <td>SEATING</td>\n",
" <td>SEATING</td>\n",
" <td>SWING SET</td>\n",
" <td>STAND-ALONE PLAY COMPONENT</td>\n",
" <td>PLAY STRUCTURE</td>\n",
" <td>SEATING</td>\n",
" <td>...</td>\n",
" <td>SEATING</td>\n",
" <td>SEATING</td>\n",
" <td>SEATING</td>\n",
" <td>STAND-ALONE PLAY COMPONENT</td>\n",
" <td>STAND-ALONE PLAY COMPONENT</td>\n",
" <td>SWING SET</td>\n",
" <td>STAND-ALONE PLAY COMPONENT</td>\n",
" <td>SEATING</td>\n",
" <td>BBQ</td>\n",
" <td>SEATING</td>\n",
" </tr>\n",
" <tr>\n",
" <th>asset_id</th>\n",
" <td>46292</td>\n",
" <td>47525</td>\n",
" <td>24478</td>\n",
" <td>22744</td>\n",
" <td>23769</td>\n",
" <td>24506</td>\n",
" <td>44743</td>\n",
" <td>45304</td>\n",
" <td>46922</td>\n",
" <td>62218</td>\n",
" <td>...</td>\n",
" <td>35198</td>\n",
" <td>24586</td>\n",
" <td>23821</td>\n",
" <td>46209</td>\n",
" <td>45287</td>\n",
" <td>62281</td>\n",
" <td>45419</td>\n",
" <td>23978</td>\n",
" <td>38673</td>\n",
" <td>22264</td>\n",
" </tr>\n",
" <tr>\n",
" <th>asset_size</th>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>1 BAY</td>\n",
" <td>N/A</td>\n",
" <td>SMALL</td>\n",
" <td>N/A</td>\n",
" <td>...</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>1 BAY</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" </tr>\n",
" <tr>\n",
" <th>asset_type</th>\n",
" <td>N/A</td>\n",
" <td>BENCH</td>\n",
" <td>BENCH</td>\n",
" <td>BENCH</td>\n",
" <td>BENCH</td>\n",
" <td>BENCH</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>2 TO 5</td>\n",
" <td>BENCH</td>\n",
" <td>...</td>\n",
" <td>PLAYERS BENCH</td>\n",
" <td>BENCH</td>\n",
" <td>BENCH</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>BENCH</td>\n",
" <td>PIT</td>\n",
" <td>BENCH</td>\n",
" </tr>\n",
" <tr>\n",
" <th>geom_type</th>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" <td>...</td>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" <td>POINT</td>\n",
" </tr>\n",
" <tr>\n",
" <th>park_id</th>\n",
" <td>1137</td>\n",
" <td>266</td>\n",
" <td>1179</td>\n",
" <td>1040</td>\n",
" <td>52</td>\n",
" <td>918</td>\n",
" <td>55</td>\n",
" <td>410</td>\n",
" <td>1137</td>\n",
" <td>59</td>\n",
" <td>...</td>\n",
" <td>1070</td>\n",
" <td>1070</td>\n",
" <td>142</td>\n",
" <td>237</td>\n",
" <td>173</td>\n",
" <td>146</td>\n",
" <td>1129</td>\n",
" <td>609</td>\n",
" <td>1313</td>\n",
" <td>747</td>\n",
" </tr>\n",
" <tr>\n",
" <th>park_name</th>\n",
" <td>Frontenac Park</td>\n",
" <td>Muriel Street Park</td>\n",
" <td>Aberdeen Adventure Playground</td>\n",
" <td>Wightman Green</td>\n",
" <td>Rotary Prairie Nature Park</td>\n",
" <td>Cordova Park</td>\n",
" <td>Scouts Park</td>\n",
" <td>Parr Tot Lot</td>\n",
" <td>Frontenac Park</td>\n",
" <td>Central Corydon C.C - River Heights Site</td>\n",
" <td>...</td>\n",
" <td>Kirkbridge Park</td>\n",
" <td>Kirkbridge Park</td>\n",
" <td>Valour C.C-Clifton Site</td>\n",
" <td>George Minaker Park</td>\n",
" <td>Pinkham Park</td>\n",
" <td>Valour C.C - Isaac Brock Site</td>\n",
" <td>Evesham Key Park</td>\n",
" <td>Paulicelli Park</td>\n",
" <td>Kilcona Park</td>\n",
" <td>Parc Joseph Royal</td>\n",
" </tr>\n",
" <tr>\n",
" <th>prim_field</th>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>...</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" <td>N/A</td>\n",
" </tr>\n",
" <tr>\n",
" <th>the_geom</th>\n",
" <td>{'type': 'Point', 'coordinates': [-97.08174796...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.29729904...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.12915711...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.22794918...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.03366551...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.18933524...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.00751582...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.14154370...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.08170560...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.18075583...</td>\n",
" <td>...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.16548156...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.16275159...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.18967885...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.27178997...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.15868988...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.18664174...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.26272864...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.02866826...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.03826030...</td>\n",
" <td>{'type': 'Point', 'coordinates': [-97.12547259...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>9 rows × 2000 columns</p>\n",
"</div>"
],
"text/plain": [
" 0 \\\n",
"asset_class STAND-ALONE PLAY COMPONENT \n",
"asset_id 46292 \n",
"asset_size N/A \n",
"asset_type N/A \n",
"geom_type POINT \n",
"park_id 1137 \n",
"park_name Frontenac Park \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.08174796... \n",
"\n",
" 1 \\\n",
"asset_class SEATING \n",
"asset_id 47525 \n",
"asset_size N/A \n",
"asset_type BENCH \n",
"geom_type POINT \n",
"park_id 266 \n",
"park_name Muriel Street Park \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.29729904... \n",
"\n",
" 2 \\\n",
"asset_class SEATING \n",
"asset_id 24478 \n",
"asset_size N/A \n",
"asset_type BENCH \n",
"geom_type POINT \n",
"park_id 1179 \n",
"park_name Aberdeen Adventure Playground \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.12915711... \n",
"\n",
" 3 \\\n",
"asset_class SEATING \n",
"asset_id 22744 \n",
"asset_size N/A \n",
"asset_type BENCH \n",
"geom_type POINT \n",
"park_id 1040 \n",
"park_name Wightman Green \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.22794918... \n",
"\n",
" 4 \\\n",
"asset_class SEATING \n",
"asset_id 23769 \n",
"asset_size N/A \n",
"asset_type BENCH \n",
"geom_type POINT \n",
"park_id 52 \n",
"park_name Rotary Prairie Nature Park \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.03366551... \n",
"\n",
" 5 \\\n",
"asset_class SEATING \n",
"asset_id 24506 \n",
"asset_size N/A \n",
"asset_type BENCH \n",
"geom_type POINT \n",
"park_id 918 \n",
"park_name Cordova Park \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.18933524... \n",
"\n",
" 6 \\\n",
"asset_class SWING SET \n",
"asset_id 44743 \n",
"asset_size 1 BAY \n",
"asset_type N/A \n",
"geom_type POINT \n",
"park_id 55 \n",
"park_name Scouts Park \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.00751582... \n",
"\n",
" 7 \\\n",
"asset_class STAND-ALONE PLAY COMPONENT \n",
"asset_id 45304 \n",
"asset_size N/A \n",
"asset_type N/A \n",
"geom_type POINT \n",
"park_id 410 \n",
"park_name Parr Tot Lot \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.14154370... \n",
"\n",
" 8 \\\n",
"asset_class PLAY STRUCTURE \n",
"asset_id 46922 \n",
"asset_size SMALL \n",
"asset_type 2 TO 5 \n",
"geom_type POINT \n",
"park_id 1137 \n",
"park_name Frontenac Park \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.08170560... \n",
"\n",
" 9 \\\n",
"asset_class SEATING \n",
"asset_id 62218 \n",
"asset_size N/A \n",
"asset_type BENCH \n",
"geom_type POINT \n",
"park_id 59 \n",
"park_name Central Corydon C.C - River Heights Site \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.18075583... \n",
"\n",
" ... \\\n",
"asset_class ... \n",
"asset_id ... \n",
"asset_size ... \n",
"asset_type ... \n",
"geom_type ... \n",
"park_id ... \n",
"park_name ... \n",
"prim_field ... \n",
"the_geom ... \n",
"\n",
" 1990 \\\n",
"asset_class SEATING \n",
"asset_id 35198 \n",
"asset_size N/A \n",
"asset_type PLAYERS BENCH \n",
"geom_type POINT \n",
"park_id 1070 \n",
"park_name Kirkbridge Park \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.16548156... \n",
"\n",
" 1991 \\\n",
"asset_class SEATING \n",
"asset_id 24586 \n",
"asset_size N/A \n",
"asset_type BENCH \n",
"geom_type POINT \n",
"park_id 1070 \n",
"park_name Kirkbridge Park \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.16275159... \n",
"\n",
" 1992 \\\n",
"asset_class SEATING \n",
"asset_id 23821 \n",
"asset_size N/A \n",
"asset_type BENCH \n",
"geom_type POINT \n",
"park_id 142 \n",
"park_name Valour C.C-Clifton Site \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.18967885... \n",
"\n",
" 1993 \\\n",
"asset_class STAND-ALONE PLAY COMPONENT \n",
"asset_id 46209 \n",
"asset_size N/A \n",
"asset_type N/A \n",
"geom_type POINT \n",
"park_id 237 \n",
"park_name George Minaker Park \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.27178997... \n",
"\n",
" 1994 \\\n",
"asset_class STAND-ALONE PLAY COMPONENT \n",
"asset_id 45287 \n",
"asset_size N/A \n",
"asset_type N/A \n",
"geom_type POINT \n",
"park_id 173 \n",
"park_name Pinkham Park \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.15868988... \n",
"\n",
" 1995 \\\n",
"asset_class SWING SET \n",
"asset_id 62281 \n",
"asset_size 1 BAY \n",
"asset_type N/A \n",
"geom_type POINT \n",
"park_id 146 \n",
"park_name Valour C.C - Isaac Brock Site \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.18664174... \n",
"\n",
" 1996 \\\n",
"asset_class STAND-ALONE PLAY COMPONENT \n",
"asset_id 45419 \n",
"asset_size N/A \n",
"asset_type N/A \n",
"geom_type POINT \n",
"park_id 1129 \n",
"park_name Evesham Key Park \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.26272864... \n",
"\n",
" 1997 \\\n",
"asset_class SEATING \n",
"asset_id 23978 \n",
"asset_size N/A \n",
"asset_type BENCH \n",
"geom_type POINT \n",
"park_id 609 \n",
"park_name Paulicelli Park \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.02866826... \n",
"\n",
" 1998 \\\n",
"asset_class BBQ \n",
"asset_id 38673 \n",
"asset_size N/A \n",
"asset_type PIT \n",
"geom_type POINT \n",
"park_id 1313 \n",
"park_name Kilcona Park \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.03826030... \n",
"\n",
" 1999 \n",
"asset_class SEATING \n",
"asset_id 22264 \n",
"asset_size N/A \n",
"asset_type BENCH \n",
"geom_type POINT \n",
"park_id 747 \n",
"park_name Parc Joseph Royal \n",
"prim_field N/A \n",
"the_geom {'type': 'Point', 'coordinates': [-97.12547259... \n",
"\n",
"[9 rows x 2000 columns]"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pd.DataFrame(parkbikedf).T"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:07.590691Z",
"start_time": "2018-03-03T22:49:07.582964Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:root:Requests made without an app_token will be subject to strict throttling limits.\n"
]
}
],
"source": [
"client = Socrata(\"data.winnipeg.ca\", None)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:07.599202Z",
"start_time": "2018-03-03T22:49:07.594577Z"
}
},
"outputs": [],
"source": [
"bikeurl = \"https://data.winnipeg.ca/resource/9t9k-ya8b.json\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:07.974047Z",
"start_time": "2018-03-03T22:49:07.602187Z"
},
"scrolled": true
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:root:Requests made without an app_token will be subject to strict throttling limits.\n"
]
}
],
"source": [
"client = Socrata(\"data.winnipeg.ca\", None)\n",
"bikes = client.get(\"9t9k-ya8b\", limit=2000)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"neighbourhood map\n",
"\n",
"https://data.winnipeg.ca/resource/xaux-29zr.json"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.618142Z",
"start_time": "2018-03-03T22:49:07.977123Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:root:Requests made without an app_token will be subject to strict throttling limits.\n"
]
}
],
"source": [
"client = Socrata(\"data.winnipeg.ca\", None)\n",
"neighbourhoods = client.get(\"xaux-29zr\", limit=2000)\n",
"import shapely.geometry\n",
"from geopandas import GeoDataFrame\n",
"neighbourhoods = GeoDataFrame(neighbourhoods)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.626792Z",
"start_time": "2018-03-03T22:49:08.621024Z"
}
},
"outputs": [],
"source": [
"import shapely.geometry\n",
"example = [x['coordinates'] for x in neighbourhoods.the_geom][0]"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.801674Z",
"start_time": "2018-03-03T22:49:08.630416Z"
}
},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'Polygon' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-20-c35807141f48>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mnewgeom\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mPolygon\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'coordinates'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mx\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mneighbourhoods\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mthe_geom\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m<ipython-input-20-c35807141f48>\u001b[0m in \u001b[0;36m<listcomp>\u001b[0;34m(.0)\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mnewgeom\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mPolygon\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'coordinates'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mx\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mneighbourhoods\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mthe_geom\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mNameError\u001b[0m: name 'Polygon' is not defined"
]
}
],
"source": [
"newgeom = [Polygon(x['coordinates'][0][0]) for x in neighbourhoods.the_geom]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.803306Z",
"start_time": "2018-03-03T22:49:05.816Z"
}
},
"outputs": [],
"source": [
"neighbourhoods['newgeom'] = newgeom\n",
"neighbourhoods = neighbourhoods.set_geometry('newgeom')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.805454Z",
"start_time": "2018-03-03T22:49:05.820Z"
}
},
"outputs": [],
"source": [
"neighbourhoods.plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.807240Z",
"start_time": "2018-03-03T22:49:05.829Z"
}
},
"outputs": [],
"source": [
"neighbourhoods"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.809377Z",
"start_time": "2018-03-03T22:49:05.833Z"
}
},
"outputs": [],
"source": [
"neighbourhoods.the_geom[0].keys()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.811461Z",
"start_time": "2018-03-03T22:49:05.837Z"
}
},
"outputs": [],
"source": [
"neighbourhoods.the_geom[0]['type']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.813522Z",
"start_time": "2018-03-03T22:49:05.841Z"
}
},
"outputs": [],
"source": [
"example = neighbourhoods.the_geom[0]['coordinates']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.815562Z",
"start_time": "2018-03-03T22:49:05.845Z"
}
},
"outputs": [],
"source": [
"example[0][0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.817605Z",
"start_time": "2018-03-03T22:49:05.849Z"
}
},
"outputs": [],
"source": [
"from shapely.geometry import Polygon\n",
"Polygon(example[0][0])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.819621Z",
"start_time": "2018-03-03T22:49:05.859Z"
}
},
"outputs": [],
"source": [
"from shapely.geometry import MultiPolygon\n",
"MultiPolygon(example)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.821602Z",
"start_time": "2018-03-03T22:49:05.864Z"
}
},
"outputs": [],
"source": [
"set(new_geom)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.823678Z",
"start_time": "2018-03-03T22:49:05.868Z"
}
},
"outputs": [],
"source": [
"gdf.DataFrame(neighbourhoods)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.826019Z",
"start_time": "2018-03-03T22:49:05.877Z"
}
},
"outputs": [],
"source": [
"import shapely.geometry"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.828181Z",
"start_time": "2018-03-03T22:49:05.884Z"
}
},
"outputs": [],
"source": [
"neipd.DataFrame(neighbourhoods)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.830145Z",
"start_time": "2018-03-03T22:49:05.894Z"
}
},
"outputs": [],
"source": [
"bikes_df = pd.DataFrame(bikes)\n",
"bikes_df.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.832160Z",
"start_time": "2018-03-03T22:49:05.898Z"
}
},
"outputs": [],
"source": [
"testcoord = bikes_df.the_geom[0]\n",
"testcoord"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.834299Z",
"start_time": "2018-03-03T22:49:05.903Z"
}
},
"outputs": [],
"source": [
"import ipyleaflet"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.836400Z",
"start_time": "2018-03-03T22:49:05.908Z"
}
},
"outputs": [],
"source": [
"!jupyter nbextension enable --py --sys-prefix ipyleaflet"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.838561Z",
"start_time": "2018-03-03T22:49:05.913Z"
}
},
"outputs": [],
"source": [
"from ipyleaflet import Map"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.840775Z",
"start_time": "2018-03-03T22:49:05.920Z"
}
},
"outputs": [],
"source": [
"Map(center = testcoord['coordinates'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.844480Z",
"start_time": "2018-03-03T22:49:05.925Z"
}
},
"outputs": [],
"source": [
"# for x in bugcleaned.location.unique():\n",
"# print(x)"
]
},
{
"cell_type": "markdown",
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T21:15:44.002394Z",
"start_time": "2018-03-03T21:15:43.996590Z"
}
},
"source": [
"https://docs.google.com/document/d/1xWBXAFSwtUGgZ3hQmzXE7ODnufQEWkji26vnsqfZzZ0/\n",
"\n",
"http://winnipeg.ca/publicworks/insectcontrol/mosquitoes/nuisanceschedule.stm\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.846467Z",
"start_time": "2018-03-03T22:49:06.174Z"
}
},
"outputs": [],
"source": [
"client = Socrata(\"data.winnipeg.ca\", None)\n",
"mapdata = \"tug6-p73s\"\n",
"mapdata = client.get(\"tug6-p73s\", limit=2000)\n",
"mapdata"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"North_east_1: 49.951867, -97.059306\n",
"North_east_2: 49.933941, -97.096341\n",
"North_east_3: 49.924809, -97.056330\n",
"North_east_4: 49.906175, -97.094797\n",
"North_east_5: 49.892358, -97.022426\n",
"North_east_6: 49.918257, -97.043848\n",
"North_east_7: 49.904900, -96.981602\n",
"North_west_1: 49.890104, -97.308464\n",
"North_west_2: 49.882624, -97.238131\n",
"North_west_3: 49.888943, -97.193254\n",
"North_west_4: 49.920877, -97.202540\n",
"North_west_5: 49.931627, -97.170450\n",
"North_west_6: 49.975104, -97.147863\n",
"North_west_7: 49.948876, -97.126311\n",
"Rural_aa: 49.981128, -97.244987\n",
"Rural_bb: 49.999793, -97.194880\n",
"Rural_cc: 49.991068, -97.089770\n",
"Rural_dd: 49.990523, -97.013920\n",
"Rural_ee: 49.852485, -96.986202\n",
"Rural_ff: 49.800355, -97.073122\n",
"Rural_gg: 49.782835, -97.339871\n",
"Rural_hh: 49.854707, -97.338403 \n",
"Rural_ii: 49.890188, -97.341707\n",
"South_east_1: 49.5242.6, 97.07156\n",
"South_east_2: 49.856801, -97.109705\n",
"south_east_3:49.859405, -97.066774\n",
"South_east_4: 49.824369, -97.133797\n",
"South_east_5: 49.829048, -97.098352\n",
"South_east_6: 49.827414, -97.060787\n",
"South_east_7: 49.806356, -97.100467\n",
"South_west_1: 49.832983, -97.332547\n",
"South_west_2: 49.852445, -97.275173\n",
"South_west_3: 49.868974, -97.243095\n",
"South_west_4: 49.868834, -97.184476\n",
"South_west_5: 49.818122, -97.165982\n",
"South_west_6: 49.805538, -97.138229\n",
"South_west_7: 49.827168, -97.170704\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.848332Z",
"start_time": "2018-03-03T22:49:06.426Z"
}
},
"outputs": [],
"source": [
"import geopandas"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.850142Z",
"start_time": "2018-03-03T22:49:06.432Z"
}
},
"outputs": [],
"source": [
"from geopandas import GeoDataFrame"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.851832Z",
"start_time": "2018-03-03T22:49:06.437Z"
}
},
"outputs": [],
"source": [
"from shapely.geometry import Point"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.853538Z",
"start_time": "2018-03-03T22:49:06.443Z"
}
},
"outputs": [],
"source": [
"mypoint = testcoord['coordinates']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.855418Z",
"start_time": "2018-03-03T22:49:06.449Z"
}
},
"outputs": [],
"source": [
"GeoDataFrame() "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.857129Z",
"start_time": "2018-03-03T22:49:06.454Z"
}
},
"outputs": [],
"source": [
"from shapely.geometry import Point"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.859171Z",
"start_time": "2018-03-03T22:49:06.463Z"
}
},
"outputs": [],
"source": [
"geotypes = [x['type'] for x in bikes_df.the_geom]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.860883Z",
"start_time": "2018-03-03T22:49:06.469Z"
}
},
"outputs": [],
"source": [
"set(geotypes)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.862732Z",
"start_time": "2018-03-03T22:49:06.476Z"
}
},
"outputs": [],
"source": [
"Point()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.864585Z",
"start_time": "2018-03-03T22:49:06.481Z"
}
},
"outputs": [],
"source": [
"newgeom = [Point(x['coordinates']) for x in bikes_df.the_geom]\n",
"bikes_df['newgeom'] = newgeom"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.866612Z",
"start_time": "2018-03-03T22:49:06.487Z"
}
},
"outputs": [],
"source": [
"gdf = bikes_df\n",
"gdf = gdf.set_geometry('newgeom')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.868884Z",
"start_time": "2018-03-03T22:49:06.492Z"
}
},
"outputs": [],
"source": [
"gdf.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.871074Z",
"start_time": "2018-03-03T22:49:06.498Z"
}
},
"outputs": [],
"source": [
"gdf.plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.873071Z",
"start_time": "2018-03-03T22:49:06.505Z"
}
},
"outputs": [],
"source": [
"gdf.set_geometry('newgeom')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.875617Z",
"start_time": "2018-03-03T22:49:06.514Z"
}
},
"outputs": [],
"source": [
"bikes_df"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.877718Z",
"start_time": "2018-03-03T22:49:06.526Z"
}
},
"outputs": [],
"source": [
"bikes_df"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.879847Z",
"start_time": "2018-03-03T22:49:06.532Z"
}
},
"outputs": [],
"source": [
"import geopandas as gpd"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.881866Z",
"start_time": "2018-03-03T22:49:06.539Z"
}
},
"outputs": [],
"source": [
"gdf = gpd.GeoDataFrame(bikes)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-03-03T22:49:08.884023Z",
"start_time": "2018-03-03T22:49:06.546Z"
}
},
"outputs": [],
"source": [
"gdf.set_geometry('the_geom')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"hide_input": false,
"kernelspec": {
"display_name": "PythonPath (python)",
"language": "python",
"name": "python_ruxi"
},
"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.4"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
},
"toc": {
"colors": {
"hover_highlight": "#DAA520",
"running_highlight": "#FF0000",
"selected_highlight": "#FFD700"
},
"moveMenuLeft": true,
"nav_menu": {
"height": "12px",
"width": "252px"
},
"navigate_menu": true,
"number_sections": true,
"sideBar": true,
"threshold": 4,
"toc_cell": false,
"toc_section_display": "block",
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment