In [1]:
import requests
import pandas as pd
In [2]:
#url = 'http://api.data.sanjoseca.gov/api/v2/datastreams/SAN-JOSE-HAULE-DATA/data.json/?auth_key=2e7ddaf15ff664d6ecfc011c307b1eec47b9b150&limit=1000#sthash.rDdhRAvy.dpuf'
#url = 'http://api.data.sanjoseca.gov/api/v2/datastreams/SAN-JOSE-HAULE-DATA/data.csv/?auth_key=2e7ddaf15ff664d6ecfc011c307b1eec47b9b150&limit=1000#sthash.rDdhRAvy.dpuf'
url = 'http://api.data.sanjoseca.gov/api/v2/datastreams/SAN-JOSE-HAULE-DATA/data.csv/?auth_key=2e7ddaf15ff664d6ecfc011c307b1eec47b9b150&limit=1000#sthash.rDdhRAvy.dpuf'
r = requests.get(url)
In [3]:
text_file = open("Output.csv", "w")
text_file.write(r.text)
text_file.close()
In [57]:
#indata = pd.read_csv("Output.csv")
indata = pd.read_csv("data/HaulerData.csv")
indata
Out[57]:
Address
PickupDay
SweepWeek
GarbageHauler
RecycleHauler
YardTrimHauler
NCUDate
StreetNumber
ZIP
WaterCompany
0
1585 WABASH ST UNIT A, ALVISO, CA 95002
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 21, 2016
1585
95002
San Jose Water Company, 408-279-7900
1
1585 WABASH ST UNIT B, ALVISO, CA 95002
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 21, 2016
1585
95002
San Jose Water Company, 408-279-7900
2
1585 WABASH ST UNIT C, ALVISO, CA 95002
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 21, 2016
1585
95002
San Jose Water Company, 408-279-7900
3
1556 GRAND BL UNIT A, ALVISO, CA 95002
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 21, 2016
1556
95002
San Jose Municipal Water System, 408-535-3500
4
1556 GRAND BL UNIT B, ALVISO, CA 95002
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 21, 2016
1556
95002
San Jose Municipal Water System, 408-535-3500
5
1556 GRAND BL UNIT C, ALVISO, CA 95002
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 21, 2016
1556
95002
San Jose Municipal Water System, 408-535-3500
6
1538 GRAND BL UNIT A, ALVISO, CA 95002
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 21, 2016
1538
95002
San Jose Water Company, 408-279-7900
7
2651 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2651
95132
San Jose Water Company, 408-279-7900
8
2645 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2645
95132
San Jose Water Company, 408-279-7900
9
2639 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2639
95132
San Jose Water Company, 408-279-7900
10
2631 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2631
95132
San Jose Water Company, 408-279-7900
11
2625 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2625
95132
San Jose Water Company, 408-279-7900
12
2619 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2619
95132
San Jose Water Company, 408-279-7900
13
2611 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2611
95132
San Jose Water Company, 408-279-7900
14
2605 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2605
95132
San Jose Water Company, 408-279-7900
15
2591 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2591
95132
San Jose Water Company, 408-279-7900
16
2565 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2565
95132
San Jose Water Company, 408-279-7900
17
2559 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2559
95132
San Jose Water Company, 408-279-7900
18
2551 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2551
95132
San Jose Water Company, 408-279-7900
19
2586 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2586
95132
San Jose Water Company, 408-279-7900
20
2600 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2600
95132
San Jose Water Company, 408-279-7900
21
2608 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2608
95132
San Jose Water Company, 408-279-7900
22
2616 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2616
95132
San Jose Water Company, 408-279-7900
23
2626 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2626
95132
San Jose Water Company, 408-279-7900
24
2634 E TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2634
95132
San Jose Water Company, 408-279-7900
25
2642 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2642
95132
San Jose Water Company, 408-279-7900
26
2652 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2652
95132
San Jose Water Company, 408-279-7900
27
2658 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2658
95132
San Jose Water Company, 408-279-7900
28
2664 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2664
95132
San Jose Water Company, 408-279-7900
29
2670 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2670
95132
San Jose Water Company, 408-279-7900
...
...
...
...
...
...
...
...
...
...
...
265578
388 SANTANA ROW UNIT 2211, SAN JOSE, CA 95128
MON
NaN
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
January 30, 2016
388
95128
San Jose Water Company, 408-279-7900
265579
388 SANTANA ROW UNIT 2220, SAN JOSE, CA 95128
MON
NaN
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
NaN
388
95128
San Jose Water Company, 408-279-7900
265580
6001 AMERICA CENTER DR STE 250, SAN JOSE, CA 9...
NaN
NaN
NaN
NaN
NaN
NaN
6001
95002
San Jose Municipal Water System, 408-535-3500
265581
9940 BUSINESS PARK DR STE 125, SACRAMENTO, CA ...
NaN
NaN
NaN
NaN
NaN
NaN
9940
95827
San Jose Water Company, 408-279-7900
265582
4636 ARMOUR DR, SANTA CLARA, CA 95054
NaN
NaN
NaN
NaN
NaN
NaN
4636
95054
San Jose Water Company, 408-279-7900
265583
2655 ROBERT FOWLER WY, SAN JOSE, CA 95148
NaN
NaN
NaN
NaN
NaN
NaN
2655
95148
San Jose Water Company, 408-279-7900
265584
442 S 22ND ST, SAN JOSE, CA 95116
THU
FRI of the 4TH WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
March 11, 2017
442
95116
San Jose Water Company, 408-279-7900
265585
2861 S BASCOM AV UNIT 702, CAMPBELL, CA 95008
NaN
NaN
NaN
NaN
NaN
NaN
2861
95008
San Jose Water Company, 408-279-7900
265586
484 S 22ND ST, SAN JOSE, CA 95116
THU
FRI of the 4TH WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
March 11, 2017
484
95116
San Jose Water Company, 408-279-7900
265587
1693 FLANIGAN DR STE 100, SAN JOSE, CA 95121
NaN
NaN
NaN
NaN
NaN
NaN
1693
95121
San Jose Municipal Water System, 408-535-3500
265588
2085 KIWI WW, SAN JOSE, CA 95133
FRI
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
December 3, 2016
2085
95133
San Jose Water Company, 408-279-7900
265589
2089 KIWI WW, SAN JOSE, CA 95133
FRI
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
2089
95133
San Jose Water Company, 408-279-7900
265590
2093 KIWI WW, SAN JOSE, CA 95133
FRI
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
2093
95133
San Jose Water Company, 408-279-7900
265591
2117 KIWI WW, SAN JOSE, CA 95133
FRI
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
2117
95133
San Jose Water Company, 408-279-7900
265592
2121 KIWI WW, SAN JOSE, CA 95133
FRI
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
2121
95133
San Jose Water Company, 408-279-7900
265593
1002 VICTORIES LP, SAN JOSE, CA 95116
THU
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
March 11, 2017
1002
95116
San Jose Water Company, 408-279-7900
265594
1012 VICTORIES LP, SAN JOSE, CA 95116
THU
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
March 11, 2017
1012
95116
San Jose Water Company, 408-279-7900
265595
1060 VICTORIES LP, SAN JOSE, CA 95116
THU
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
March 11, 2017
1060
95116
San Jose Water Company, 408-279-7900
265596
546 S 22ND ST, SAN JOSE, CA 95116
THU
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
546
95116
San Jose Water Company, 408-279-7900
265597
1506 NELEIGH PL, SAN JOSE, CA 95131
MON
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
1506
95131
San Jose Water Company, 408-279-7900
265598
2556 HERON CT, SAN JOSE, CA 95133
FRI
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
2556
95133
San Jose Water Company, 408-279-7900
265599
1648 SHORE DR, SAN JOSE, CA 95131
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
NaN
1648
95131
San Jose Water Company, 408-279-7900
265600
1638 SHORE DR, SAN JOSE, CA 95131
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
NaN
1638
95131
San Jose Water Company, 408-279-7900
265601
1622 SHORE DR, SAN JOSE, CA 95131
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 20, 2017
1622
95131
San Jose Water Company, 408-279-7900
265602
1630 VENDRE PL, SAN JOSE, CA 95131
MON
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
September 26, 2015
1630
95131
San Jose Water Company, 408-279-7900
265603
1656 VENDRE PL, SAN JOSE, CA 95131
MON
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
1656
95131
San Jose Water Company, 408-279-7900
265604
1623 MURASKY PL, SAN JOSE, CA 95131
MON
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 20, 2017
1623
95131
San Jose Water Company, 408-279-7900
265605
1557 MERCADO WY, SAN JOSE, CA 95131
MON
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
1557
95131
San Jose Water Company, 408-279-7900
265606
1035 E BROKAW RD, SAN JOSE, CA 95131
NaN
NaN
NaN
NaN
NaN
NaN
1035
95131
San Jose Water Company, 408-279-7900
265607
1045 E BROKAW RD, SAN JOSE, CA 95131
NaN
NaN
NaN
NaN
NaN
NaN
1045
95131
San Jose Water Company, 408-279-7900
265608 rows × 10 columns
In [58]:
from geopy.geocoders import Nominatim
import geocoder
In [8]:
geolocator = Nominatim()
In [47]:
g = geocoder.google("1585 WABASH ST UNIT A, ALVISO, CA 95002")
In [48]:
g.geojson
Out[48]:
{'bbox': [-121.9673639802915,
37.43053301970851,
-121.9646660197085,
37.43323098029151],
'geometry': {'coordinates': [-121.966015, 37.43188200000001],
'type': 'Point'},
'properties': {'accuracy': 'ROOFTOP',
'address': '1585 Wabash St, Alviso, CA 95002, USA',
'bbox': [-121.9673639802915,
37.43053301970851,
-121.9646660197085,
37.43323098029151],
'city': 'San Jose',
'confidence': 9,
'country': 'US',
'county': 'Santa Clara County',
'encoding': 'utf-8',
'housenumber': '1585',
'lat': 37.43188200000001,
'lng': -121.966015,
'location': '1585 WABASH ST UNIT A, ALVISO, CA 95002',
'neighborhood': 'Alviso',
'ok': True,
'postal': '95002',
'provider': 'google',
'quality': 'subpremise',
'state': 'CA',
'status': 'OK',
'status_code': 200,
'street': 'Wabash St',
'subpremise': 'a'},
'type': 'Feature'}
In [49]:
g.city
Out[49]:
'San Jose'
In [36]:
location = geolocator.geocode("1585 WABASH ST UNIT A, ALVISO, CA 95002")
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
//anaconda/lib/python3.5/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
1239 try:
-> 1240 h.request(req.get_method(), req.selector, req.data, headers)
1241 except OSError as err: # timeout error
//anaconda/lib/python3.5/http/client.py in request(self, method, url, body, headers)
1082 """Send a complete request to the server."""
-> 1083 self._send_request(method, url, body, headers)
1084
//anaconda/lib/python3.5/http/client.py in _send_request(self, method, url, body, headers)
1127 body = body.encode('iso-8859-1')
-> 1128 self.endheaders(body)
1129
//anaconda/lib/python3.5/http/client.py in endheaders(self, message_body)
1078 raise CannotSendHeader()
-> 1079 self._send_output(message_body)
1080
//anaconda/lib/python3.5/http/client.py in _send_output(self, message_body)
910
--> 911 self.send(msg)
912 if message_body is not None:
//anaconda/lib/python3.5/http/client.py in send(self, data)
853 if self.auto_open:
--> 854 self.connect()
855 else:
//anaconda/lib/python3.5/http/client.py in connect(self)
1228
-> 1229 super().connect()
1230
//anaconda/lib/python3.5/http/client.py in connect(self)
825 self.sock = self._create_connection(
--> 826 (self.host,self.port), self.timeout, self.source_address)
827 self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
//anaconda/lib/python3.5/socket.py in create_connection(address, timeout, source_address)
710 if err is not None:
--> 711 raise err
712 else:
//anaconda/lib/python3.5/socket.py in create_connection(address, timeout, source_address)
701 sock.bind(source_address)
--> 702 sock.connect(sa)
703 return sock
OSError: [Errno 65] No route to host
During handling of the above exception, another exception occurred:
URLError Traceback (most recent call last)
//anaconda/lib/python3.5/site-packages/geopy/geocoders/base.py in _call_geocoder(self, url, timeout, raw, requester, deserializer, **kwargs)
142 try:
--> 143 page = requester(req, timeout=(timeout or self.timeout), **kwargs)
144 except Exception as error: # pylint: disable=W0703
//anaconda/lib/python3.5/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
161 opener = _opener
--> 162 return opener.open(url, data, timeout)
163
//anaconda/lib/python3.5/urllib/request.py in open(self, fullurl, data, timeout)
464
--> 465 response = self._open(req, data)
466
//anaconda/lib/python3.5/urllib/request.py in _open(self, req, data)
482 result = self._call_chain(self.handle_open, protocol, protocol +
--> 483 '_open', req)
484 if result:
//anaconda/lib/python3.5/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
442 func = getattr(handler, meth_name)
--> 443 result = func(*args)
444 if result is not None:
//anaconda/lib/python3.5/urllib/request.py in https_open(self, req)
1282 return self.do_open(http.client.HTTPSConnection, req,
-> 1283 context=self._context, check_hostname=self._check_hostname)
1284
//anaconda/lib/python3.5/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
1241 except OSError as err: # timeout error
-> 1242 raise URLError(err)
1243 r = h.getresponse()
URLError: <urlopen error [Errno 65] No route to host>
During handling of the above exception, another exception occurred:
GeocoderServiceError Traceback (most recent call last)
<ipython-input-36-4a983fd460ae> in <module>()
----> 1 location = geolocator.geocode("1585 WABASH ST UNIT A, ALVISO, CA 95002")
//anaconda/lib/python3.5/site-packages/geopy/geocoders/osm.py in geocode(self, query, exactly_one, timeout, addressdetails, language, geometry)
191 logger.debug("%s.geocode: %s", self.__class__.__name__, url)
192 return self._parse_json(
--> 193 self._call_geocoder(url, timeout=timeout), exactly_one
194 )
195
//anaconda/lib/python3.5/site-packages/geopy/geocoders/base.py in _call_geocoder(self, url, timeout, raw, requester, deserializer, **kwargs)
169 if "timed out" in message:
170 raise GeocoderTimedOut('Service timed out')
--> 171 raise GeocoderServiceError(message)
172
173 if hasattr(page, 'getcode'):
GeocoderServiceError: [Errno 65] No route to host
In [31]:
print(location.address)
1585, Wabash Street, Alviso, San José, Santa Clara County, California, 95002, United States of America
In [37]:
location = geolocator.geocode("1585 WABASH ST, ALVISO, CA 95002")
In [38]:
location.raw
Out[38]:
{'boundingbox': ['37.43183602155',
'37.43193602155',
'-121.96635286491',
'-121.96625286491'],
'class': 'place',
'display_name': '1585, Wabash Street, Alviso, San José, Santa Clara County, California, 95002, United States of America',
'importance': 0.401,
'lat': '37.43188602155',
'licence': 'Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright',
'lon': '-121.966302864912',
'place_id': '490986840',
'type': 'house'}
In [40]:
location
Out[40]:
Location(1585, Wabash Street, Alviso, San José, Santa Clara County, California, 95002, United States of America, (37.43188602155, -121.966302864912, 0.0))
In [ ]:
print(location.address)
Flatiron Building, 175, 5th Avenue, Flatiron, New York, NYC, New York, ...
>>> print((location.latitude, location.longitude))
(40.7410861, -73.9896297241625)
>>> print(location.raw)
{'place_id': '9167009604', 'type': 'attraction', ...}
In [51]:
#http://wiki.openstreetmap.org/wiki/Developer_FAQ
How to get around
File "<ipython-input-51-d3187d0d4c7b>", line 2
How to get around
^
IndentationError: unexpected indent
In [60]:
def dowToNum(val):
lookup={"MON":0,"TUE":1,"WED":2,"THU":3,"FRI":4}
if val != val: return -1
return lookup[val]
In [ ]:
In [59]:
indata["PickupDay"].unique()
Out[59]:
array(['MON', 'FRI', nan, 'THU', 'WED', 'TUE'], dtype=object)
In [61]:
indata["PickupDayNum"] = indata["PickupDay"].apply(dowToNum)
indata
Out[61]:
Address
PickupDay
SweepWeek
GarbageHauler
RecycleHauler
YardTrimHauler
NCUDate
StreetNumber
ZIP
WaterCompany
PickupDayNum
0
1585 WABASH ST UNIT A, ALVISO, CA 95002
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 21, 2016
1585
95002
San Jose Water Company, 408-279-7900
0
1
1585 WABASH ST UNIT B, ALVISO, CA 95002
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 21, 2016
1585
95002
San Jose Water Company, 408-279-7900
0
2
1585 WABASH ST UNIT C, ALVISO, CA 95002
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 21, 2016
1585
95002
San Jose Water Company, 408-279-7900
0
3
1556 GRAND BL UNIT A, ALVISO, CA 95002
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 21, 2016
1556
95002
San Jose Municipal Water System, 408-535-3500
0
4
1556 GRAND BL UNIT B, ALVISO, CA 95002
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 21, 2016
1556
95002
San Jose Municipal Water System, 408-535-3500
0
5
1556 GRAND BL UNIT C, ALVISO, CA 95002
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 21, 2016
1556
95002
San Jose Municipal Water System, 408-535-3500
0
6
1538 GRAND BL UNIT A, ALVISO, CA 95002
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 21, 2016
1538
95002
San Jose Water Company, 408-279-7900
0
7
2651 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2651
95132
San Jose Water Company, 408-279-7900
4
8
2645 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2645
95132
San Jose Water Company, 408-279-7900
4
9
2639 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2639
95132
San Jose Water Company, 408-279-7900
4
10
2631 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2631
95132
San Jose Water Company, 408-279-7900
4
11
2625 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2625
95132
San Jose Water Company, 408-279-7900
4
12
2619 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2619
95132
San Jose Water Company, 408-279-7900
4
13
2611 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2611
95132
San Jose Water Company, 408-279-7900
4
14
2605 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2605
95132
San Jose Water Company, 408-279-7900
4
15
2591 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2591
95132
San Jose Water Company, 408-279-7900
4
16
2565 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2565
95132
San Jose Water Company, 408-279-7900
4
17
2559 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2559
95132
San Jose Water Company, 408-279-7900
4
18
2551 POPLARWOOD WY, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2551
95132
San Jose Water Company, 408-279-7900
4
19
2586 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2586
95132
San Jose Water Company, 408-279-7900
4
20
2600 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2600
95132
San Jose Water Company, 408-279-7900
4
21
2608 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2608
95132
San Jose Water Company, 408-279-7900
4
22
2616 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2616
95132
San Jose Water Company, 408-279-7900
4
23
2626 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2626
95132
San Jose Water Company, 408-279-7900
4
24
2634 E TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2634
95132
San Jose Water Company, 408-279-7900
4
25
2642 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2642
95132
San Jose Water Company, 408-279-7900
4
26
2652 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2652
95132
San Jose Water Company, 408-279-7900
4
27
2658 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2658
95132
San Jose Water Company, 408-279-7900
4
28
2664 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2664
95132
San Jose Water Company, 408-279-7900
4
29
2670 TRIMBLE RD, SAN JOSE, CA 95132
FRI
MON of the 3RD WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
June 4, 2016
2670
95132
San Jose Water Company, 408-279-7900
4
...
...
...
...
...
...
...
...
...
...
...
...
265578
388 SANTANA ROW UNIT 2211, SAN JOSE, CA 95128
MON
NaN
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
January 30, 2016
388
95128
San Jose Water Company, 408-279-7900
0
265579
388 SANTANA ROW UNIT 2220, SAN JOSE, CA 95128
MON
NaN
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
NaN
388
95128
San Jose Water Company, 408-279-7900
0
265580
6001 AMERICA CENTER DR STE 250, SAN JOSE, CA 9...
NaN
NaN
NaN
NaN
NaN
NaN
6001
95002
San Jose Municipal Water System, 408-535-3500
-1
265581
9940 BUSINESS PARK DR STE 125, SACRAMENTO, CA ...
NaN
NaN
NaN
NaN
NaN
NaN
9940
95827
San Jose Water Company, 408-279-7900
-1
265582
4636 ARMOUR DR, SANTA CLARA, CA 95054
NaN
NaN
NaN
NaN
NaN
NaN
4636
95054
San Jose Water Company, 408-279-7900
-1
265583
2655 ROBERT FOWLER WY, SAN JOSE, CA 95148
NaN
NaN
NaN
NaN
NaN
NaN
2655
95148
San Jose Water Company, 408-279-7900
-1
265584
442 S 22ND ST, SAN JOSE, CA 95116
THU
FRI of the 4TH WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
March 11, 2017
442
95116
San Jose Water Company, 408-279-7900
3
265585
2861 S BASCOM AV UNIT 702, CAMPBELL, CA 95008
NaN
NaN
NaN
NaN
NaN
NaN
2861
95008
San Jose Water Company, 408-279-7900
-1
265586
484 S 22ND ST, SAN JOSE, CA 95116
THU
FRI of the 4TH WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
March 11, 2017
484
95116
San Jose Water Company, 408-279-7900
3
265587
1693 FLANIGAN DR STE 100, SAN JOSE, CA 95121
NaN
NaN
NaN
NaN
NaN
NaN
1693
95121
San Jose Municipal Water System, 408-535-3500
-1
265588
2085 KIWI WW, SAN JOSE, CA 95133
FRI
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
December 3, 2016
2085
95133
San Jose Water Company, 408-279-7900
4
265589
2089 KIWI WW, SAN JOSE, CA 95133
FRI
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
2089
95133
San Jose Water Company, 408-279-7900
4
265590
2093 KIWI WW, SAN JOSE, CA 95133
FRI
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
2093
95133
San Jose Water Company, 408-279-7900
4
265591
2117 KIWI WW, SAN JOSE, CA 95133
FRI
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
2117
95133
San Jose Water Company, 408-279-7900
4
265592
2121 KIWI WW, SAN JOSE, CA 95133
FRI
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
2121
95133
San Jose Water Company, 408-279-7900
4
265593
1002 VICTORIES LP, SAN JOSE, CA 95116
THU
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
March 11, 2017
1002
95116
San Jose Water Company, 408-279-7900
3
265594
1012 VICTORIES LP, SAN JOSE, CA 95116
THU
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
March 11, 2017
1012
95116
San Jose Water Company, 408-279-7900
3
265595
1060 VICTORIES LP, SAN JOSE, CA 95116
THU
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
March 11, 2017
1060
95116
San Jose Water Company, 408-279-7900
3
265596
546 S 22ND ST, SAN JOSE, CA 95116
THU
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
546
95116
San Jose Water Company, 408-279-7900
3
265597
1506 NELEIGH PL, SAN JOSE, CA 95131
MON
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
1506
95131
San Jose Water Company, 408-279-7900
0
265598
2556 HERON CT, SAN JOSE, CA 95133
FRI
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
2556
95133
San Jose Water Company, 408-279-7900
4
265599
1648 SHORE DR, SAN JOSE, CA 95131
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
NaN
1648
95131
San Jose Water Company, 408-279-7900
0
265600
1638 SHORE DR, SAN JOSE, CA 95131
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
NaN
1638
95131
San Jose Water Company, 408-279-7900
0
265601
1622 SHORE DR, SAN JOSE, CA 95131
MON
TUE of the 1ST WEEK
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 20, 2017
1622
95131
San Jose Water Company, 408-279-7900
0
265602
1630 VENDRE PL, SAN JOSE, CA 95131
MON
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
September 26, 2015
1630
95131
San Jose Water Company, 408-279-7900
0
265603
1656 VENDRE PL, SAN JOSE, CA 95131
MON
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
1656
95131
San Jose Water Company, 408-279-7900
0
265604
1623 MURASKY PL, SAN JOSE, CA 95131
MON
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
Green Waste Recovery, 408-283-4800
May 20, 2017
1623
95131
San Jose Water Company, 408-279-7900
0
265605
1557 MERCADO WY, SAN JOSE, CA 95131
MON
NONHAUL-PRIVATE
Garden City Sanitation, 408-988-4500
California Waste Solutions, 408-213-7800
NaN
NaN
1557
95131
San Jose Water Company, 408-279-7900
0
265606
1035 E BROKAW RD, SAN JOSE, CA 95131
NaN
NaN
NaN
NaN
NaN
NaN
1035
95131
San Jose Water Company, 408-279-7900
-1
265607
1045 E BROKAW RD, SAN JOSE, CA 95131
NaN
NaN
NaN
NaN
NaN
NaN
1045
95131
San Jose Water Company, 408-279-7900
-1
265608 rows × 11 columns
In [15]:
import usaddress
In [22]:
addr=usaddress.tag(indata["Address"][1])
addr
Out[22]:
(OrderedDict([('AddressNumber', '1585'),
('StreetName', 'WABASH'),
('StreetNamePostType', 'ST'),
('OccupancyType', 'UNIT'),
('OccupancyIdentifier', 'B'),
('PlaceName', 'ALVISO'),
('StateName', 'CA'),
('ZipCode', '95002')]),
'Street Address')
In [23]:
ad = dict(addr[0])
ad
Out[23]:
{'AddressNumber': '1585',
'OccupancyIdentifier': 'B',
'OccupancyType': 'UNIT',
'PlaceName': 'ALVISO',
'StateName': 'CA',
'StreetName': 'WABASH',
'StreetNamePostType': 'ST',
'ZipCode': '95002'}
In [26]:
addrstr = ad['AddressNumber'] + ' ' + ad['StateName'] + ' '
addrstr
Out[26]:
'1585 CA '
In [27]:
from collections import defaultdict
defadd = defaultdict(lambda: '', dict(addr[0]))
addrstr2 = defadd["StreetNamePreDirectional"] + ' ' + defadd["StreetName"] + " " + defadd["StreetNamePostDirectional"]
addrstr3 = ' '.join(addrstr2.split())
In [35]:
addr[0]
Out[35]:
OrderedDict([('AddressNumber', '1585'),
('StreetName', 'WABASH'),
('StreetNamePostType', 'ST'),
('OccupancyType', 'UNIT'),
('OccupancyIdentifier', 'B'),
('PlaceName', 'ALVISO'),
('StateName', 'CA'),
('ZipCode', '95002')])
In [37]:
addr[0].values()
Out[37]:
odict_values(['1585', 'WABASH', 'ST', 'UNIT', 'B', 'ALVISO', 'CA', '95002'])
In [38]:
addr[0]['StreetName']
Out[38]:
'WABASH'
In [39]:
location = geolocator.geocode("1585 WABASH ST, ALVISO, CA, 95002")
location
Out[39]:
Location(1585, Wabash Street, Alviso, San José, Santa Clara County, California, 95002, United States of America, (37.43188602155, -121.966302864912, 0.0))
In [41]:
location = geolocator.geocode("1585 WABASH ST UNIT A, ALVISO, CA 95002")
In [40]:
print((location.latitude, location.longitude))
print(location.raw)
(37.43188602155, -121.966302864912)
{'place_id': '490986840', 'class': 'place', 'lon': '-121.966302864912', 'licence': 'Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright', 'boundingbox': ['37.43183602155', '37.43193602155', '-121.96635286491', '-121.96625286491'], 'type': 'house', 'lat': '37.43188602155', 'importance': 0.401, 'display_name': '1585, Wabash Street, Alviso, San José, Santa Clara County, California, 95002, United States of America'}
In [55]:
indata["PickupDay"].unique()
Out[55]:
array(['MON', 'FRI', nan, 'THU'], dtype=object)
In [ ]:
Content source: codeforsanjose/trash-pickup-portal
Similar notebooks:
notebook.community | gallery | about