-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_town.py
67 lines (44 loc) · 1.5 KB
/
get_town.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import nbd_geocode
import csv
with open("town_train.csv", "w") as g:
town_train = csv.writer(g)
with open("neighborhood_train.csv", "r") as f:
nbd_train = csv.reader(f)
for i in nbd_train:
listing = i[0]
nbd = i[1]
if nbd in nbd_geocode.m_nbd:
town_train.writerow([listing, "manhattan"])
if nbd in nbd_geocode.b_nbd:
town_train.writerow([listing, "boston"])
if nbd in nbd_geocode.q_nbd:
town_train.writerow([listing, "queens"])
if nbd in nbd_geocode.bx_nbd:
town_train.writerow([listing, "bronx"])
if nbd in nbd_geocode.j_nbd:
town_train.writerow([listing, "jersey"])
if nbd in nbd_geocode.s_nbd:
town_train.writerow([listing, "stratten"])
if nbd in nbd_geocode.college_nbd:
town_train.writerow([listing, "college"])
with open("town_test.csv", "w") as g:
town_test = csv.writer(g)
with open("neighborhood_test.csv", "r") as f:
nbd_test = csv.reader(f)
for i in nbd_test:
listing = i[0]
nbd = i[1]
if nbd in nbd_geocode.m_nbd:
town_test.writerow([listing, "manhattan"])
if nbd in nbd_geocode.b_nbd:
town_test.writerow([listing, "boston"])
if nbd in nbd_geocode.q_nbd:
town_test.writerow([listing, "queens"])
if nbd in nbd_geocode.bx_nbd:
town_test.writerow([listing, "bronx"])
if nbd in nbd_geocode.j_nbd:
town_test.writerow([listing, "jersey"])
if nbd in nbd_geocode.s_nbd:
town_test.writerow([listing, "stratten"])
if nbd in nbd_geocode.college_nbd:
town_test.writerow([listing, "college"])