In [1]:
%matplotlib inline
In [33]:
import geopandas as gpd
import pandas as pd
import numpy as np
import seaborn
import dask.dataframe as dd
from matplotlib import pyplot as plt
In [5]:
bike = dd.read_parquet('/bigdata/citibike.parquet')
In [6]:
bike.head()
Out[6]:
trip_duration
start_time
stop_time
start_station_id
start_station_name
start_station_latitude
start_station_longitude
end_station_id
end_station_name
end_station_latitude
end_station_longitude
bike_id
user_type
birth_year
gender
start_taxizone_id
end_taxizone_id
start_ct_id
end_ct_id
0
634
2013-07-01 00:00:00
2013-07-01 00:10:34
164
E 47 St & 2 Ave
40.753231
-73.970322
504
1 Ave & E 15 St
40.732220
-73.981659
16950
Customer
NaN
0
233.0
224.0
1432.0
2158.0
1
1547
2013-07-01 00:00:02
2013-07-01 00:25:49
388
W 26 St & 10 Ave
40.749718
-74.002953
459
W 20 St & 11 Ave
40.746746
-74.007759
19816
Customer
NaN
0
246.0
246.0
2098.0
2098.0
2
178
2013-07-01 00:01:04
2013-07-01 00:04:02
293
Lafayette St & E 8 St
40.730286
-73.990768
237
E 11 St & 2 Ave
40.730473
-73.986725
14548
Subscriber
1980.0
2
113.0
79.0
1472.0
861.0
3
1580
2013-07-01 00:01:06
2013-07-01 00:27:26
531
Forsyth St & Broome St
40.718941
-73.992661
499
Broadway & W 60 St
40.769154
-73.981918
16063
Customer
NaN
0
148.0
142.0
1475.0
1346.0
4
757
2013-07-01 00:01:10
2013-07-01 00:13:47
382
University Pl & E 14 St
40.734928
-73.992004
410
Suffolk St & Stanton St
40.720665
-73.985176
19213
Subscriber
1986.0
1
113.0
148.0
969.0
929.0
In [11]:
zz = bike['trip_duration start_ct_id'.split()].groupby('start_ct_id').count().compute()
In [24]:
zz = zz.sort_index()
zz.index = zz.index.astype(np.int64)
zz.columns = ['biketrip_count',]
In [61]:
bikesmall = bike['start_station_latitude start_station_longitude start_ct_id'.split()]
bike2 = bikesmall[bikesmall.start_ct_id == 9].compute()
In [62]:
bike2
Out[62]:
start_station_latitude
start_station_longitude
start_ct_id
1676
40.720875
-73.980858
9.0
2545
40.720875
-73.980858
9.0
3113
40.720875
-73.980858
9.0
3329
40.720875
-73.980858
9.0
3339
40.720875
-73.980858
9.0
3419
40.720875
-73.980858
9.0
3711
40.720875
-73.980858
9.0
3763
40.720875
-73.980858
9.0
4049
40.720875
-73.980858
9.0
4243
40.720875
-73.980858
9.0
4269
40.720875
-73.980858
9.0
4317
40.720875
-73.980858
9.0
4360
40.720875
-73.980858
9.0
4569
40.720875
-73.980858
9.0
4583
40.720875
-73.980858
9.0
4586
40.720875
-73.980858
9.0
4739
40.720875
-73.980858
9.0
4741
40.720875
-73.980858
9.0
4841
40.720875
-73.980858
9.0
5139
40.720875
-73.980858
9.0
7740
40.720875
-73.980858
9.0
7900
40.720875
-73.980858
9.0
8311
40.720875
-73.980858
9.0
8742
40.720875
-73.980858
9.0
10987
40.720875
-73.980858
9.0
12882
40.720875
-73.980858
9.0
12998
40.720875
-73.980858
9.0
13134
40.720875
-73.980858
9.0
13675
40.720875
-73.980858
9.0
14201
40.720875
-73.980858
9.0
...
...
...
...
38192
40.720875
-73.980858
9.0
38269
40.720875
-73.980858
9.0
38289
40.720875
-73.980858
9.0
38290
40.720875
-73.980858
9.0
38291
40.720875
-73.980858
9.0
38298
40.720875
-73.980858
9.0
38498
40.720875
-73.980858
9.0
38626
40.720875
-73.980858
9.0
39191
40.720875
-73.980858
9.0
39680
40.720875
-73.980858
9.0
39681
40.720875
-73.980858
9.0
40174
40.720875
-73.980858
9.0
40248
40.720875
-73.980858
9.0
41768
40.720875
-73.980858
9.0
43287
40.720875
-73.980858
9.0
45198
40.720875
-73.980858
9.0
45480
40.720875
-73.980858
9.0
46523
40.720875
-73.980858
9.0
47132
40.720875
-73.980858
9.0
47215
40.720875
-73.980858
9.0
47216
40.720875
-73.980858
9.0
47264
40.720875
-73.980858
9.0
47330
40.720875
-73.980858
9.0
48096
40.720875
-73.980858
9.0
48097
40.720875
-73.980858
9.0
48183
40.720875
-73.980858
9.0
48654
40.720875
-73.980858
9.0
48706
40.720875
-73.980858
9.0
48762
40.720875
-73.980858
9.0
51071
40.720875
-73.980858
9.0
74799 rows × 3 columns
In [54]:
zz
Out[54]:
biketrip_count
start_ct_id
9
74799
10
430761
11
242609
12
474650
13
228317
14
131138
15
257177
16
142856
17
241261
18
178008
20
132012
21
672318
22
27447
23
38145
24
85521
25
3139
26
47407
27
7187
29
4636
30
40977
31
21306
33
2023
54
56658
55
1103
56
37623
63
4940
64
5573
65
12196
80
2734
82
3622
...
...
2037
473707
2040
262070
2043
63137
2047
19787
2048
42559
2063
2997
2081
23797
2082
50779
2090
11260
2095
511843
2098
705033
2099
308199
2100
496842
2101
148639
2102
421357
2103
215798
2104
114130
2112
166862
2123
17863
2124
11633
2133
42592
2146
135173
2148
64526
2152
246529
2155
100156
2156
34091
2157
100684
2158
436600
2163
42561
2164
57101
309 rows × 1 columns
In [55]:
ct = gpd.read_file('../shapefiles/nyct2010.shp')
ct
Out[55]:
BoroCT2010
BoroCode
BoroName
CDEligibil
CT2010
CTLabel
NTACode
NTAName
PUMA
Shape_Area
Shape_Leng
geometry
0
5000900
5
Staten Island
I
000900
9
SI22
West New Brighton-New Brighton-St. George
3903
2.497010e+06
7729.016729
POLYGON ((962269.1260375977 173705.5001831055,...
1
5012500
5
Staten Island
I
012500
125
SI22
West New Brighton-New Brighton-St. George
3903
4.954936e+06
10582.855530
POLYGON ((951998.5532226562 168438.0043945312,...
2
5013301
5
Staten Island
E
013301
133.01
SI22
West New Brighton-New Brighton-St. George
3903
7.217847e+05
3428.312676
POLYGON ((951720.9486083984 170488.4069824219,...
3
5019700
5
Staten Island
I
019700
197
SI07
Westerleigh
3903
3.231720e+06
9097.697226
POLYGON ((947819.2308349609 164190.0209960938,...
4
5002002
5
Staten Island
I
002002
20.02
SI14
Grasmere-Arrochar-Ft. Wadsworth
3902
8.501224e+06
12591.725901
POLYGON ((966615.2556152344 158662.2927856445,...
5
5006400
5
Staten Island
I
006400
64
SI14
Grasmere-Arrochar-Ft. Wadsworth
3902
7.643184e+06
12726.360406
POLYGON ((963023.891784668 158246.7521972656, ...
6
5007400
5
Staten Island
I
007400
74
SI14
Grasmere-Arrochar-Ft. Wadsworth
3902
5.788238e+06
9902.948475
POLYGON ((967656.8290405273 155637.1314086914,...
7
5018701
5
Staten Island
I
018701
187.01
SI07
Westerleigh
3903
4.267476e+06
8626.771269
POLYGON ((950555.9412231445 161453.658203125, ...
8
1002202
1
Manhattan
I
002202
22.02
MN28
Lower East Side
3809
6.039223e+05
3817.391631
POLYGON ((990284.3284301758 201838.3563842773,...
9
1003200
1
Manhattan
I
003200
32
MN22
East Village
3809
2.334190e+06
6358.386684
POLYGON ((989819.2963867188 204093.9949951172,...
10
1006800
1
Manhattan
I
006800
68
MN21
Gramercy
3808
1.877943e+06
5723.883037
POLYGON ((989553.9097900391 209596.7955932617,...
11
1008900
1
Manhattan
I
008900
89
MN13
Hudson Yards-Chelsea-Flatiron-Union Square
3807
1.782279e+06
5578.769499
POLYGON ((984534.7501831055 210565.4451904297,...
12
1009600
1
Manhattan
E
009600
96
MN17
Midtown-Midtown South
3807
1.887288e+06
5737.356247
POLYGON ((990440.5057983398 215405.0643920898,...
13
1009800
1
Manhattan
I
009800
98
MN19
Turtle Bay-East Midtown
3808
1.906016e+06
5534.199811
POLYGON ((994133.507019043 214848.8975830078, ...
14
1010000
1
Manhattan
I
010000
100
MN19
Turtle Bay-East Midtown
3808
1.860938e+06
5692.168488
POLYGON ((993108.3057861328 216013.1307983398,...
15
1010200
1
Manhattan
I
010200
102
MN17
Midtown-Midtown South
3807
1.860993e+06
5687.802579
POLYGON ((992216.5391845703 216507.6870117188,...
16
1010400
1
Manhattan
I
010400
104
MN17
Midtown-Midtown South
3807
1.864600e+06
5693.036118
POLYGON ((991325.8814086914 217001.6885986328,...
17
1011201
1
Manhattan
I
011201
112.01
MN17
Midtown-Midtown South
3807
8.561644e+05
3716.146785
POLYGON ((991725.2440185547 217725.2991943359,...
18
1011202
1
Manhattan
I
011202
112.02
MN17
Midtown-Midtown South
3807
8.395258e+05
3688.762328
POLYGON ((992615.8984375 217228.1416015625, 99...
19
1011203
1
Manhattan
I
011203
112.03
MN19
Turtle Bay-East Midtown
3808
8.540825e+05
3701.173031
POLYGON ((993507.2319946289 216732.0338134766,...
20
1011300
1
Manhattan
I
011300
113
MN17
Midtown-Midtown South
3807
1.890907e+06
5699.860641
POLYGON ((988650.2766113281 214286.4022216797,...
21
1011402
1
Manhattan
I
011402
114.02
MN40
Upper East Side-Carnegie Hill
3805
1.063547e+06
4125.256100
POLYGON ((994013.2479858398 217645.299621582, ...
22
1013000
1
Manhattan
I
013000
130
MN40
Upper East Side-Carnegie Hill
3805
1.918145e+06
5807.972956
POLYGON ((994920.1096191406 221386.2695922852,...
23
1014000
1
Manhattan
I
014000
140
MN40
Upper East Side-Carnegie Hill
3805
1.925984e+06
5820.815640
POLYGON ((996728.3079833984 222545.6896362305,...
24
1014200
1
Manhattan
I
014200
142
MN40
Upper East Side-Carnegie Hill
3805
1.927688e+06
5821.704944
POLYGON ((995836.4956054688 223039.7406005859,...
25
1014601
1
Manhattan
I
014601
146.01
MN32
Yorkville
3805
7.998799e+05
4016.133393
POLYGON ((998271.5236206055 222317.6588134766,...
26
1014602
1
Manhattan
I
014602
146.02
MN32
Yorkville
3805
1.175339e+06
4528.695483
POLYGON ((998660.5087890625 223021.3121948242,...
27
1014801
1
Manhattan
I
014801
148.01
MN40
Upper East Side-Carnegie Hill
3805
5.592162e+05
3135.951423
POLYGON ((996994.3508300781 223026.0794067383,...
28
1014802
1
Manhattan
I
014802
148.02
MN40
Upper East Side-Carnegie Hill
3805
1.351365e+06
4691.029341
POLYGON ((997637.4860229492 224187.0347900391,...
29
1015300
1
Manhattan
I
015300
153
MN14
Lincoln Square
3806
1.872393e+06
5674.292342
POLYGON ((990644.7542114258 221597.942199707, ...
...
...
...
...
...
...
...
...
...
...
...
...
...
2136
2021800
2
Bronx
E
021800
218
BX08
West Farms-Bronx River
3709
3.460969e+06
9122.453686
POLYGON ((1021107.376037598 243458.9674072266,...
2137
2024000
2
Bronx
E
024000
240
BX37
Van Nest-Morris Park-Westchester Square
3704
2.577349e+06
7190.177079
POLYGON ((1021556.863220215 246239.2802124023,...
2138
2006000
2
Bronx
E
006000
60
BX75
Crotona Park East
3705
3.413187e+06
7818.412089
POLYGON ((1017867.582641602 245337.3627929688,...
2139
2006200
2
Bronx
E
006200
62
BX08
West Farms-Bronx River
3709
2.035611e+06
7175.713453
POLYGON ((1019153.905639648 243875.9155883789,...
2140
3030300
3
Brooklyn
E
030300
303
BK79
Ocean Hill
4007
2.690240e+06
6898.560842
POLYGON ((1008188.862182617 185753.8187866211,...
2141
3036501
3
Brooklyn
E
036501
365.01
BK79
Ocean Hill
4007
1.369715e+06
5483.369156
POLYGON ((1008957.26940918 185699.4918212891, ...
2142
3079602
3
Brooklyn
E
079602
796.02
BK60
Prospect Lefferts Gardens-Wingate
4011
1.453525e+06
5043.967955
POLYGON ((996507.9182128906 176285.0225830078,...
2143
3082000
3
Brooklyn
E
082000
820
BK60
Prospect Lefferts Gardens-Wingate
4011
1.599913e+06
5582.419306
POLYGON ((998104.8178100586 178068.6047973633,...
2144
3082200
3
Brooklyn
E
082200
822
BK60
Prospect Lefferts Gardens-Wingate
4011
1.827423e+06
5792.844437
POLYGON ((997439.182800293 176336.3872070312, ...
2145
1003400
1
Manhattan
I
003400
34
MN22
East Village
3809
1.718946e+06
5503.345191
POLYGON ((990340.0073852539 205029.4624023438,...
2146
3090000
3
Brooklyn
E
090000
900
BK81
Brownsville
4007
2.645351e+06
6709.231083
POLYGON ((1007479.828186035 181438.7852172852,...
2147
3000900
3
Brooklyn
I
000900
9
BK09
Brooklyn Heights-Cobble Hill
4004
1.737777e+06
5883.375467
POLYGON ((986838.3345947266 192326.7385864258,...
2148
3036100
3
Brooklyn
E
036100
361
BK79
Ocean Hill
4007
1.524421e+06
6064.700108
POLYGON ((1007864.663391113 183580.8475952148,...
2149
3078200
3
Brooklyn
E
078200
782
BK91
East Flatbush-Farragut
4010
1.811374e+06
5948.145346
POLYGON ((1001592.999633789 171330.1213989258,...
2150
3083000
3
Brooklyn
E
083000
830
BK91
East Flatbush-Farragut
4010
2.171915e+06
6600.753863
POLYGON ((1000207.434997559 172073.5809936523,...
2151
1006000
1
Manhattan
I
006000
60
MN50
Stuyvesant Town-Cooper Village
3808
1.296018e+06
5239.096008
POLYGON ((991333.3630371094 207173.3526000977,...
2152
3031300
3
Brooklyn
E
031300
313
BK61
Crown Heights North
4006
1.832522e+06
5465.787220
POLYGON ((999740.874206543 186352, 999901.1726...
2153
3031500
3
Brooklyn
E
031500
315
BK61
Crown Heights North
4006
1.886108e+06
5658.750760
POLYGON ((998973.1525878906 186411.3536376953,...
2154
3019300
3
Brooklyn
E
019300
193
BK69
Clinton Hill
4004
2.903179e+06
6981.649815
POLYGON ((995501.4732055664 190827.6047973633,...
2155
3023300
3
Brooklyn
E
023300
233
BK75
Bedford
4003
1.849442e+06
5438.790291
POLYGON ((996695.8309936523 190462.5628051758,...
2156
1002800
1
Manhattan
E
002800
28
MN28
Lower East Side
3809
1.973562e+06
5627.595336
POLYGON ((991650.9154052734 204299.32421875, 9...
2157
1004400
1
Manhattan
I
004400
44
MN50
Stuyvesant Town-Cooper Village
3808
4.277454e+06
9684.842507
(POLYGON ((994681.4056396484 203127.6748046875...
2158
4137700
4
Queens
I
137700
1377
QN42
Oakland Gardens
4104
8.038804e+06
12085.908028
POLYGON ((1052563.640808105 209850.8568115234,...
2159
4138502
4
Queens
I
138502
1385.02
QN99
park-cemetery-etc-Queens
4104
2.620882e+07
48473.195704
POLYGON ((1054368.627197266 217912.8056030273,...
2160
1028700
1
Manhattan
E
028700
287
MN35
Washington Heights North
3801
5.710876e+06
12407.587938
POLYGON ((1003963.362792969 255062.9552001953,...
2161
1029700
1
Manhattan
I
029700
297
MN99
park-cemetery-etc-Manhattan
3801
9.961849e+06
20553.099113
(POLYGON ((1004601.953430176 259027.5151977539...
2162
3000100
3
Brooklyn
I
000100
1
BK09
Brooklyn Heights-Cobble Hill
4004
2.237282e+06
6527.281839
POLYGON ((986764.3486328125 194584.6243896484,...
2163
3000301
3
Brooklyn
I
000301
3.01
BK09
Brooklyn Heights-Cobble Hill
4004
2.142139e+06
6466.952122
POLYGON ((985832.7232055664 193771.6766357422,...
2164
1023300
1
Manhattan
E
023300
233
MN04
Hamilton Heights
3802
2.535724e+06
7136.778935
POLYGON ((999389.0635986328 241090.4204101562,...
2165
1023700
1
Manhattan
E
023700
237
MN04
Hamilton Heights
3802
2.897558e+06
7073.400099
POLYGON ((1000029.442993164 242245.0491943359,...
2166 rows × 12 columns
In [56]:
ct = ct.to_crs({'init': 'epsg:4326'})
In [57]:
ct2 = ct.merge(zz, left_index=True, right_index=True, how='left')
In [58]:
ct2.biketrip_count = np.log(ct2.biketrip_count.fillna(1))
In [59]:
sorted(ct2.CTLabel.unique().tolist())
Out[59]:
['1',
'10',
'10.01',
'10.02',
'100',
'1004',
'1006',
'1008',
'1008.01',
'1008.02',
'101',
'1010',
'1010.01',
'1010.02',
'1012',
'1014',
'1016',
'1017',
'1018',
'102',
'1020',
'1022',
'1024',
'1026',
'1028',
'1029',
'103',
'1032.01',
'1032.02',
'1033',
'1034',
'1039',
'104',
'1047',
'105',
'1058.01',
'1058.04',
'1059',
'106',
'106.01',
'106.02',
'107.01',
'1070',
'1072.01',
'1072.02',
'1078',
'108',
'1085',
'109',
'1093',
'1097',
'1098',
'1099',
'11',
'110',
'1104',
'1106',
'111',
'1110',
'1113',
'1116',
'1118',
'112',
'112.01',
'112.02',
'112.03',
'1120',
'1122',
'1123',
'1124',
'1126',
'1128',
'1129',
'113',
'1130',
'1132',
'1133',
'1134',
'1139',
'114',
'114.01',
'114.02',
'1141',
'1142.01',
'1142.02',
'1144',
'1146',
'1147',
'115',
'115.02',
'1150',
'1151',
'1152',
'1155',
'1156',
'1157',
'1158',
'1159',
'116',
'1160',
'1161',
'1162',
'1163',
'1164',
'1166',
'1167',
'1168',
'117',
'1170',
'1171',
'1172.01',
'1172.02',
'1174',
'1175',
'1176.01',
'1176.02',
'1178',
'118',
'1180',
'1181',
'1182.01',
'1182.02',
'1184',
'1185',
'1186',
'1187',
'1188',
'1189',
'119',
'1190',
'1191',
'1192',
'1193',
'1194',
'1195',
'1196',
'1198',
'1199',
'12',
'120',
'1200',
'1201',
'1202',
'1203',
'1205',
'1207',
'1208',
'121',
'121.01',
'121.02',
'1210',
'1211',
'1214',
'1215',
'122',
'1220',
'1223',
'1227.01',
'1227.02',
'123',
'123.01',
'1237',
'124',
'1241',
'1247',
'125',
'1257',
'126',
'126.01',
'126.02',
'1265',
'1267',
'127',
'127.01',
'1277',
'128',
'128.01',
'128.04',
'128.05',
'128.06',
'1283',
'129',
'129.01',
'129.02',
'1291.02',
'1291.03',
'1291.04',
'13',
'130',
'1301',
'131',
'132',
'132.01',
'132.03',
'132.04',
'133',
'133.01',
'133.02',
'1333',
'1339',
'134',
'1341',
'1347',
'135',
'136',
'1367',
'137',
'1377',
'138',
'1385.01',
'1385.02',
'139',
'1399',
'14',
'14.01',
'14.02',
'140',
'1403',
'1409.01',
'1409.02',
'141',
'1417',
'142',
'142.01',
'142.02',
'1429',
'143',
'1435',
'144',
'144.01',
'144.02',
'1441',
'1447',
'145',
'1451.01',
'1451.02',
'1459',
'146.01',
'146.02',
'146.04',
'146.05',
'146.06',
'146.07',
'146.08',
'1463',
'1467',
'147',
'147.01',
'147.02',
'1471',
'1479',
'148',
'148.01',
'148.02',
'1483',
'149',
'15',
'15.01',
'15.02',
'150',
'150.01',
'150.02',
'1502',
'1507.01',
'1507.02',
'151',
'152',
'1522',
'1529.01',
'1529.02',
'153',
'154',
'155',
'1551.01',
'1551.02',
'156',
'156.01',
'156.02',
'156.03',
'1567',
'157',
'1571.01',
'1571.02',
'1579.01',
'1579.02',
'1579.03',
'158',
'158.01',
'158.02',
'159',
'16',
'160',
'160.01',
'160.02',
'161',
'1617',
'162',
'1621',
'163',
'164',
'165',
'166',
'167',
'168',
'169',
'169.01',
'17',
'170',
'170.05',
'170.07',
'170.08',
'170.09',
'170.10',
'170.11',
'170.12',
'171',
'172',
'173',
'174',
'174.01',
'174.02',
'175',
'176',
'177',
'177.01',
'177.02',
'178',
'179',
'179.01',
'179.02',
'18',
'180',
'181',
'181.01',
'181.02',
'182',
'183',
'183.01',
'183.02',
'184',
'184.01',
'184.02',
'185',
'185.01',
'185.02',
'186',
'187',
'187.01',
'187.02',
'188',
'189',
'189.01',
'189.02',
'19',
'190',
'191',
'192',
'193',
'194',
'195',
'196',
'197',
'197.01',
'197.02',
'198',
'199',
'2',
'2.01',
'2.02',
'20',
'20.01',
'20.02',
'200',
'201',
'201.01',
'201.02',
'202',
'203',
'204',
'205',
'205.01',
'205.02',
'206',
'206.01',
'207',
'207.01',
'208',
'208.01',
'208.03',
'208.04',
'209',
'209.01',
'21',
'210',
'210.01',
'210.02',
'211',
'212',
'213',
'213.01',
'213.02',
'213.03',
'214',
'215',
'215.01',
'215.02',
'216',
'216.01',
'216.02',
'217',
'217.03',
'218',
'219',
'22',
'22.01',
'22.02',
'220',
'220.01',
'220.02',
'221',
'221.01',
'221.02',
'222',
'223',
'223.01',
'223.02',
'224',
'224.01',
'224.03',
'224.04',
'225',
'226',
'227',
'227.01',
'227.02',
'227.03',
'228',
'229',
'229.01',
'229.02',
'23',
'230',
'231',
'232',
'233',
'233.01',
'233.02',
'234',
'235',
'235.01',
'235.02',
'236',
'237',
'237.02',
'237.03',
'237.04',
'238',
'238.01',
'238.02',
'239',
'24',
'240',
'241',
'242',
'243',
'243.01',
'243.02',
'244',
'244.01',
'244.02',
'245',
'245.01',
'245.02',
'246',
'247',
'248',
'249',
'25',
'250',
'251',
'252',
'253',
'253.01',
'253.02',
'254',
'255',
'256',
'257',
'258',
'259',
'259.01',
'259.02',
'26',
'26.01',
'26.02',
'260',
'261',
'262',
'263',
'264',
'265',
'266',
'266.01',
'266.02',
'267',
'267.01',
'267.02',
'268',
'269',
'269.01',
'269.02',
'27',
'27.01',
'27.02',
'270',
'271',
'272',
'273',
'273.01',
'273.02',
'274',
'274.01',
'274.02',
'275',
'276',
'277',
'277.02',
'277.04',
'277.05',
'277.06',
'278',
'279',
'28',
'280',
'281',
'282',
'283',
'284',
'285',
'285.01',
'285.02',
'286',
'287',
'288',
'289',
'29',
'29.01',
'290',
'291',
'291.02',
'291.03',
'291.04',
'292',
'293',
'293.01',
'293.02',
'294',
'295',
'296',
'297',
'298',
'299',
'3',
'3.01',
'30',
'30.01',
'30.02',
'300',
'301',
'302',
'303',
'303.01',
'303.02',
'304',
'305',
'306',
'307',
'307.01',
'308',
'309',
'309.02',
'309.03',
'309.04',
'31',
'310',
'311',
'312',
'313',
'314',
'315',
'316',
'317',
'317.01',
'317.02',
'317.03',
'317.04',
'318',
'319',
'319.01',
'319.02',
'32',
'320',
'321',
'323',
'324',
'325',
'326',
'327',
'328',
'329',
'33',
'330',
'331',
'332.01',
'332.02',
'333',
'334',
'334.01',
'334.02',
'335',
'336',
'337',
'338',
'339',
'34',
'340',
'341',
'342',
'343',
'344',
'345',
'347',
'348',
'349',
'35',
'350',
'351',
'352',
'353',
'354',
'355',
'356',
'356.01',
'356.02',
'357',
'358',
'359',
'36',
'36.01',
'36.02',
'360',
'360.01',
'360.02',
'361',
'362',
'363',
'364',
'365',
'365.01',
'365.02',
'366',
'367',
'368',
'369',
'369.01',
'369.02',
'37',
'370',
'371',
'372',
'373',
'374',
'374.01',
'374.02',
'375',
'375.04',
'376',
'377',
'378',
'379',
'38',
'380',
'381',
'382',
'383',
'383.01',
'383.02',
'384',
'385',
'386',
'387',
'388',
'389',
'39',
'390',
'391',
'392',
'393',
'394',
'395',
'396',
'397',
'398',
'399',
'399.01',
'399.02',
'4',
'40',
'40.01',
'40.02',
'400',
'401',
'402',
'403',
'403.02',
'403.03',
'403.04',
'404',
'405',
'405.01',
'405.02',
'406',
'407',
'407.01',
'407.02',
'408',
'409',
'41',
'410',
'411',
'412',
'413',
'414',
'414.01',
'414.02',
'415',
'416',
'417',
'418',
'419',
'42',
'420',
'421',
'422',
'423',
'424',
'425',
'426',
'427',
'428',
'429',
'429.01',
'429.02',
'43',
'430',
'431',
'432',
'433',
'434',
'435',
'436',
'437',
'437.01',
'437.02',
'438',
'439',
'44',
'44.01',
'440',
'441',
'442',
'443',
'443.01',
'443.02',
'444',
'445',
'446',
'446.01',
'446.02',
'447',
'448',
'449',
'449.01',
'449.02',
'45',
'450',
'451.01',
'451.02',
'452',
'453',
'454',
'455',
'456',
'457',
'458',
'459',
'46',
'460',
'461',
'462',
'462.01',
'462.02',
'463',
'464',
'465',
'466',
'467',
'468',
'469',
'47',
'470',
'471',
'472',
'473',
'474',
'475',
'476',
'477',
'478',
'479',
'48',
'480',
'481',
'482',
'483',
'484',
'485',
'486',
'488',
'489',
'49',
'490',
'491',
'492',
'493',
'493.01',
'493.02',
'494',
'495',
'496',
'497',
'498',
'499',
'5',
'5.01',
'5.02',
'50',
'50.01',
'50.02',
'500',
'501',
'502.01',
'502.02',
'503',
'504',
'505',
'506',
'507',
'508',
'508.01',
'508.03',
'508.04',
'509',
'51',
'510',
'510.01',
'510.02',
'511',
'512',
'513',
'514',
'515',
'516',
'516.01',
'516.02',
'517',
'518',
'519',
'52',
'52.01',
'52.02',
'520',
'521',
'522',
'523',
'524',
'525',
'526',
'527',
'528',
'529',
'53',
'530',
'531',
'532',
'533',
'534',
'534.01',
'535',
'536.01',
'537',
'538',
'539',
'54',
'540',
'542',
'543',
'544',
'545',
'546',
'547',
'548',
'549',
'55',
'55.01',
'55.02',
'550',
'551',
'552',
'553',
'554',
'555',
'556',
'557',
'558',
'559',
'56',
'56.01',
'56.02',
'560',
'561',
'562',
'563',
'564',
'565',
'566',
'567',
'568',
'569',
'57',
'570',
'571',
'572',
'573',
'574',
'575',
'576',
'577',
'578',
'579',
'58',
'580',
'581',
'582',
'583',
'584',
'585',
'586',
'587',
'588',
'589',
'59',
'59.02',
'590',
'591',
'592',
'593',
'594',
'594.01',
'594.02',
'595',
'596',
'598',
'599',
'6',
'60',
'600',
'601',
'603',
'606',
'607.01',
'608',
'61',
'610',
'610.02',
'610.03',
'610.04',
'612',
'613.01',
'613.02',
'614',
'616',
'616.01',
'616.02',
'618',
'619',
'62',
'62.01',
'62.02',
'620',
...]
The white point should be inside the zone indicated by the red point. Google maps that is a 6 minute difference in location walking, which is quite a lot. Something is very broken about the spatial join.
In [75]:
ct2.plot('biketrip_count', cmap=plt.cm.viridis)
plt.plot([-73.980858,], [40.720875, ] , 'o', color='white')
plt.plot(-73.98370854854818, 40.72555342330404, 'o', color='red')
plt.gcf().set_size_inches(12, 9)
plt.xlim(-74.0, -73.95)
plt.ylim(40.7, 40.75)
Out[75]:
(40.7, 40.75)
In [42]:
!ls
citibike_cleaning_nb.ipynb stations.2017.04.20.09.43.json
derby.log subway_test_1.ipynb
exploratory_bike_station_ids.ipynb subway_test_2.ipynb
lowfreq_bike_stations.ipynb Untitled.ipynb
sql_test_1.ipynb
In [ ]:
zz = bike['trip_duration start_ct_id'.split()].groupby('start_ct_id').count().compute()
In [73]:
print(ct.geometry[9].centroid)
POINT (-73.98370854854818 40.72555342330404)
In [52]:
tz = gpd.read_file('../shapefiles/taxi_zones.shp')
tz.to_crs({'init': 'epsg:4326'})
Out[52]:
LocationID
OBJECTID
Shape_Area
Shape_Leng
borough
geometry
zone
0
1
1
0.000782
0.116357
EWR
POLYGON ((-74.18445299999996 40.6949959999999,...
Newark Airport
1
2
2
0.004866
0.433470
Queens
(POLYGON ((-73.82337597260663 40.6389870471767...
Jamaica Bay
2
3
3
0.000314
0.084341
Bronx
POLYGON ((-73.84792614099985 40.87134223399991...
Allerton/Pelham Gardens
3
4
4
0.000112
0.043567
Manhattan
POLYGON ((-73.97177410965318 40.72582128133705...
Alphabet City
4
5
5
0.000498
0.092146
Staten Island
POLYGON ((-74.17421738099989 40.56256808599987...
Arden Heights
5
6
6
0.000606
0.150491
Staten Island
POLYGON ((-74.06367318899999 40.60219816599994...
Arrochar/Fort Wadsworth
6
7
7
0.000390
0.107417
Queens
POLYGON ((-73.90413637799996 40.76752031699986...
Astoria
7
8
8
0.000027
0.027591
Queens
POLYGON ((-73.92334041500001 40.77512891199993...
Astoria Park
8
9
9
0.000338
0.099784
Queens
POLYGON ((-73.78502434699996 40.76103651599986...
Auburndale
9
10
10
0.000436
0.099839
Queens
POLYGON ((-73.7832662499999 40.68999429299992,...
Baisley Park
10
11
11
0.000265
0.079211
Brooklyn
POLYGON ((-74.00109809499993 40.60303462599992...
Bath Beach
11
12
12
0.000042
0.036661
Manhattan
POLYGON ((-74.01565756599994 40.70483308799993...
Battery Park
12
13
13
0.000149
0.050281
Manhattan
POLYGON ((-74.01244109299991 40.7190576729999,...
Battery Park City
13
14
14
0.001382
0.175214
Brooklyn
POLYGON ((-74.03407329297129 40.64431393298185...
Bay Ridge
14
15
15
0.000925
0.144336
Queens
POLYGON ((-73.7774039129087 40.79659824126783,...
Bay Terrace/Fort Totten
15
16
16
0.000872
0.141292
Queens
POLYGON ((-73.7685730499999 40.77910542899991,...
Bayside
16
17
17
0.000323
0.093523
Brooklyn
POLYGON ((-73.94306406899986 40.70142443499989...
Bedford
17
18
18
0.000149
0.069800
Bronx
POLYGON ((-73.88513907699999 40.86638287399992...
Bedford Park
18
19
19
0.000547
0.101825
Queens
POLYGON ((-73.72339596299987 40.75038907599986...
Bellerose
19
20
20
0.000135
0.051440
Bronx
POLYGON ((-73.88386792099986 40.8642908889999,...
Belmont
20
21
21
0.000380
0.115974
Brooklyn
POLYGON ((-73.97418385499991 40.6094635019999,...
Bensonhurst East
21
22
22
0.000472
0.126170
Brooklyn
POLYGON ((-73.99254973599997 40.62427426799996...
Bensonhurst West
22
23
23
0.002196
0.290556
Staten Island
POLYGON ((-74.19568609223377 40.63501686464005...
Bloomfield/Emerson Hill
23
24
24
0.000061
0.047000
Manhattan
POLYGON ((-73.95953658899998 40.7987185259999,...
Bloomingdale
24
25
25
0.000124
0.047146
Brooklyn
POLYGON ((-73.98155298299992 40.68914616399994...
Boerum Hill
25
26
26
0.000534
0.123548
Brooklyn
POLYGON ((-73.98331628499983 40.6414786819999,...
Borough Park
26
27
27
0.001341
0.202509
Queens
POLYGON ((-73.86522555399998 40.57045847199989...
Breezy Point/Fort Tilden/Riis Beach
27
28
28
0.000291
0.097961
Queens
POLYGON ((-73.79240413399991 40.71619304099993...
Briarwood/Jamaica Hills
28
29
29
0.000202
0.071408
Brooklyn
POLYGON ((-73.96004798699995 40.58326987199995...
Brighton Beach
29
30
30
0.000146
0.094510
Queens
POLYGON ((-73.82075892499992 40.61523267899991...
Broad Channel
...
...
...
...
...
...
...
...
233
234
234
0.000073
0.036072
Manhattan
POLYGON ((-73.98996936399989 40.73490456699994...
Union Sq
234
235
235
0.000213
0.076167
Bronx
POLYGON ((-73.90947862999988 40.86180812899987...
University Heights/Morris Heights
235
236
236
0.000103
0.044252
Manhattan
POLYGON ((-73.95779380499984 40.77359989699993...
Upper East Side North
236
237
237
0.000096
0.042213
Manhattan
POLYGON ((-73.9661274729999 40.76217929999991,...
Upper East Side South
237
238
238
0.000185
0.060109
Manhattan
POLYGON ((-73.96884378999985 40.78596738899994...
Upper West Side North
238
239
239
0.000205
0.063626
Manhattan
POLYGON ((-73.97501417199996 40.78768560599987...
Upper West Side South
239
240
240
0.000722
0.146070
Bronx
POLYGON ((-73.87643743099994 40.89687059299995...
Van Cortlandt Park
240
241
241
0.000255
0.068765
Bronx
POLYGON ((-73.88840157099996 40.88441707499993...
Van Cortlandt Village
241
242
242
0.000360
0.138136
Bronx
POLYGON ((-73.83593362199987 40.84840635599993...
Van Nest/Morris Park
242
243
243
0.000438
0.094331
Manhattan
POLYGON ((-73.93156536999994 40.86958215799991...
Washington Heights North
243
244
244
0.000360
0.080569
Manhattan
POLYGON ((-73.94068822000003 40.85131543299985...
Washington Heights South
244
245
245
0.000466
0.095983
Staten Island
POLYGON ((-74.09787969199995 40.64035805499988...
West Brighton
245
246
246
0.000281
0.069467
Manhattan
POLYGON ((-74.00439976203513 40.76267135909888...
West Chelsea/Hudson Yards
246
247
247
0.000206
0.092968
Bronx
POLYGON ((-73.91222180499983 40.84235659099988...
West Concourse
247
248
248
0.000150
0.056919
Bronx
POLYGON ((-73.86393748099981 40.84004456599994...
West Farms/Bronx River
248
249
249
0.000072
0.036384
Manhattan
POLYGON ((-74.00250642399995 40.72901638499997...
West Village
249
250
250
0.000241
0.079626
Bronx
POLYGON ((-73.8455308949999 40.83917330699989,...
Westchester Village/Unionport
250
251
251
0.000626
0.137711
Staten Island
POLYGON ((-74.13107460299996 40.63114772899996...
Westerleigh
251
252
252
0.001025
0.158004
Queens
POLYGON ((-73.82049919995306 40.80101146781907...
Whitestone
252
253
253
0.000078
0.036051
Queens
POLYGON ((-73.83908354399988 40.76525691299991...
Willets Point
253
254
254
0.000360
0.085886
Bronx
POLYGON ((-73.85186563799999 40.87905886499989...
Williamsbridge/Olinville
254
255
255
0.000172
0.062384
Brooklyn
POLYGON ((-73.96176070375392 40.72522879205536...
Williamsburg (North Side)
255
256
256
0.000169
0.067915
Brooklyn
POLYGON ((-73.95834207500002 40.71330630099992...
Williamsburg (South Side)
256
257
257
0.000139
0.058669
Brooklyn
POLYGON ((-73.97984261899994 40.66072744099996...
Windsor Terrace
257
258
258
0.000366
0.089013
Queens
POLYGON ((-73.84504194899991 40.68931894699996...
Woodhaven
258
259
259
0.000395
0.126750
Bronx
POLYGON ((-73.85107116191899 40.91037152011096...
Woodlawn/Wakefield
259
260
260
0.000422
0.133514
Queens
POLYGON ((-73.9017537339999 40.76077547499995,...
Woodside
260
261
261
0.000034
0.027120
Manhattan
POLYGON ((-74.01332610899989 40.7050307879999,...
World Trade Center
261
262
262
0.000122
0.049064
Manhattan
(POLYGON ((-73.94383256699986 40.7828590889999...
Yorkville East
262
263
263
0.000066
0.037017
Manhattan
POLYGON ((-73.95218621999996 40.7730198449999,...
Yorkville West
263 rows × 7 columns
In [53]:
tz.plot()
Out[53]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fdb6dc399b0>
In [ ]:
Content source: r-shekhar/NYC-transport
Similar notebooks: