Below I've outlined a couple of examples of pattern mining with afdata.
You can download the data from the Bay Area Bike Share's website.
In [5]:
import pandas as pd
df = pd.read_csv('../datasets/babs_open_data_year_1/201402_babs_open_data/201402_trip_data.csv')
In [6]:
df
Out[6]:
Trip ID
Duration
Start Date
Start Station
Start Terminal
End Date
End Station
End Terminal
Bike #
Subscription Type
Zip Code
0
4576
63
8/29/2013 14:13
South Van Ness at Market
66
8/29/2013 14:14
South Van Ness at Market
66
520
Subscriber
94127
1
4607
70
8/29/2013 14:42
San Jose City Hall
10
8/29/2013 14:43
San Jose City Hall
10
661
Subscriber
95138
2
4130
71
8/29/2013 10:16
Mountain View City Hall
27
8/29/2013 10:17
Mountain View City Hall
27
48
Subscriber
97214
3
4251
77
8/29/2013 11:29
San Jose City Hall
10
8/29/2013 11:30
San Jose City Hall
10
26
Subscriber
95060
4
4299
83
8/29/2013 12:02
South Van Ness at Market
66
8/29/2013 12:04
Market at 10th
67
319
Subscriber
94103
5
4927
103
8/29/2013 18:54
Golden Gate at Polk
59
8/29/2013 18:56
Golden Gate at Polk
59
527
Subscriber
94109
6
4500
109
8/29/2013 13:25
Santa Clara at Almaden
4
8/29/2013 13:27
Adobe on Almaden
5
679
Subscriber
95112
7
4563
111
8/29/2013 14:02
San Salvador at 1st
8
8/29/2013 14:04
San Salvador at 1st
8
687
Subscriber
95112
8
4760
113
8/29/2013 17:01
South Van Ness at Market
66
8/29/2013 17:03
South Van Ness at Market
66
553
Subscriber
94103
9
4258
114
8/29/2013 11:33
San Jose City Hall
10
8/29/2013 11:35
MLK Library
11
107
Subscriber
95060
10
4549
125
8/29/2013 13:52
Spear at Folsom
49
8/29/2013 13:55
Embarcadero at Bryant
54
368
Subscriber
94109
11
4498
126
8/29/2013 13:23
San Pedro Square
6
8/29/2013 13:25
Santa Clara at Almaden
4
26
Subscriber
95112
12
4965
129
8/29/2013 19:32
Mountain View Caltrain Station
28
8/29/2013 19:35
Mountain View Caltrain Station
28
140
Subscriber
94041
13
4557
130
8/29/2013 13:57
2nd at South Park
64
8/29/2013 13:59
2nd at South Park
64
371
Subscriber
94122
14
4386
134
8/29/2013 12:31
Clay at Battery
41
8/29/2013 12:33
Beale at Market
56
503
Subscriber
94109
15
4749
138
8/29/2013 16:57
Post at Kearney
47
8/29/2013 16:59
Post at Kearney
47
408
Subscriber
94117
16
4242
141
8/29/2013 11:25
San Jose City Hall
10
8/29/2013 11:27
San Jose City Hall
10
26
Subscriber
95060
17
4329
142
8/29/2013 12:11
Market at 10th
67
8/29/2013 12:14
Market at 10th
67
319
Subscriber
94103
18
5097
142
8/29/2013 22:21
Steuart at Market
74
8/29/2013 22:24
Harry Bridges Plaza (Ferry Building)
50
564
Subscriber
94115
19
5084
144
8/29/2013 22:06
Powell Street BART
39
8/29/2013 22:08
Market at 4th
76
574
Subscriber
94115
20
4982
146
8/29/2013 19:42
Spear at Folsom
49
8/29/2013 19:44
Embarcadero at Bryant
54
542
Subscriber
94105
21
4417
148
8/29/2013 12:45
Redwood City Caltrain Station
22
8/29/2013 12:48
Redwood City Caltrain Station
22
159
Subscriber
94061
22
4265
151
8/29/2013 11:40
San Francisco City Hall
58
8/29/2013 11:42
San Francisco City Hall
58
520
Subscriber
94110
23
5093
160
8/29/2013 22:12
Post at Kearney
47
8/29/2013 22:14
Market at Sansome
77
442
Subscriber
94115
24
4168
161
8/29/2013 10:56
Beale at Market
56
8/29/2013 10:59
Steuart at Market
74
414
Customer
94117
25
4550
163
8/29/2013 13:53
Japantown
9
8/29/2013 13:56
Japantown
9
684
Subscriber
95112
26
4533
165
8/29/2013 13:43
Temporary Transbay Terminal (Howard at Beale)
55
8/29/2013 13:46
Embarcadero at Folsom
51
365
Subscriber
94109
27
4510
166
8/29/2013 13:31
San Jose Civic Center
3
8/29/2013 13:34
San Salvador at 1st
8
661
Subscriber
95112
28
5070
168
8/29/2013 21:43
South Van Ness at Market
66
8/29/2013 21:46
South Van Ness at Market
66
598
Subscriber
94115
29
4917
169
8/29/2013 18:45
Redwood City Medical Center
26
8/29/2013 18:48
Broadway at Main
25
229
Subscriber
94041
...
...
...
...
...
...
...
...
...
...
...
...
143985
198739
196
2/28/2014 19:44
Mountain View City Hall
27
2/28/2014 19:48
Mountain View Caltrain Station
28
134
Subscriber
94401
143986
198742
197
2/28/2014 20:06
Golden Gate at Polk
59
2/28/2014 20:09
Civic Center BART (7th at Market)
72
562
Subscriber
94114
143987
198743
552
2/28/2014 20:10
Embarcadero at Bryant
54
2/28/2014 20:19
Howard at 2nd
63
315
Customer
10028
143988
198744
528
2/28/2014 20:11
Embarcadero at Bryant
54
2/28/2014 20:19
Howard at 2nd
63
619
Customer
10028
143989
198745
435
2/28/2014 20:15
5th at Howard
57
2/28/2014 20:22
San Francisco Caltrain (Townsend at 4th)
70
618
Subscriber
95110
143990
198746
293
2/28/2014 20:16
Market at 10th
67
2/28/2014 20:20
Powell Street BART
39
317
Subscriber
94107
143991
198747
466
2/28/2014 20:16
Market at 10th
67
2/28/2014 20:24
Market at 4th
76
384
Subscriber
94108
143992
198748
250
2/28/2014 20:17
Howard at 2nd
63
2/28/2014 20:21
2nd at Townsend
61
277
Subscriber
94107
143993
198749
760
2/28/2014 20:18
Market at 4th
76
2/28/2014 20:31
San Francisco Caltrain 2 (330 Townsend)
69
481
Subscriber
94102
143994
198750
254
2/28/2014 20:22
Townsend at 7th
65
2/28/2014 20:26
San Francisco Caltrain (Townsend at 4th)
70
268
Subscriber
94107
143995
198751
160
2/28/2014 20:24
Market at Sansome
77
2/28/2014 20:26
Commercial at Montgomery
45
425
Subscriber
94111
143996
198752
471
2/28/2014 20:25
Market at 4th
76
2/28/2014 20:33
Davis at Jackson
42
614
Subscriber
94108
143997
198753
1010
2/28/2014 20:26
Market at 4th
76
2/28/2014 20:43
Davis at Jackson
42
384
Subscriber
94111
143998
198754
293
2/28/2014 20:26
Market at Sansome
77
2/28/2014 20:31
Washington at Kearney
46
286
Subscriber
94107
143999
198755
1463
2/28/2014 20:28
Redwood City Public Library
24
2/28/2014 20:53
Cowper at University
37
90
Subscriber
94061
144000
198757
277
2/28/2014 20:40
Mountain View Caltrain Station
28
2/28/2014 20:45
Castro Street and El Camino Real
32
129
Subscriber
94040
144001
198760
598
2/28/2014 20:59
Market at Sansome
77
2/28/2014 21:09
South Van Ness at Market
66
283
Subscriber
94102
144002
198761
399
2/28/2014 20:59
Market at Sansome
77
2/28/2014 21:06
Civic Center BART (7th at Market)
72
337
Subscriber
94103
144003
198763
685
2/28/2014 21:32
Clay at Battery
41
2/28/2014 21:43
Post at Kearney
47
606
Customer
56006
144004
198764
168
2/28/2014 21:32
2nd at Townsend
61
2/28/2014 21:35
San Francisco Caltrain (Townsend at 4th)
70
427
Subscriber
94107
144005
198765
429
2/28/2014 21:34
Embarcadero at Bryant
54
2/28/2014 21:41
San Francisco Caltrain 2 (330 Townsend)
69
433
Subscriber
94105
144006
198766
342
2/28/2014 21:41
Market at Sansome
77
2/28/2014 21:46
Yerba Buena Center of the Arts (3rd @ Howard)
68
398
Subscriber
94105
144007
198767
744
2/28/2014 21:50
South Van Ness at Market
66
2/28/2014 22:03
Post at Kearney
47
511
Subscriber
94702
144008
198768
225
2/28/2014 21:54
2nd at Folsom
62
2/28/2014 21:57
Yerba Buena Center of the Arts (3rd @ Howard)
68
635
Subscriber
94107
144009
198770
850
2/28/2014 22:19
Townsend at 7th
65
2/28/2014 22:34
Post at Kearney
47
479
Subscriber
94108
144010
198771
385
2/28/2014 22:15
Powell Street BART
39
2/28/2014 22:22
South Van Ness at Market
66
483
Subscriber
94404
144011
198772
145
2/28/2014 22:38
Commercial at Montgomery
45
2/28/2014 22:40
Davis at Jackson
42
425
Subscriber
94111
144012
198773
677
2/28/2014 22:45
Embarcadero at Sansome
60
2/28/2014 22:56
Market at 4th
76
438
Subscriber
94102
144013
198774
64128
2/28/2014 23:01
Civic Center BART (7th at Market)
72
3/1/2014 16:50
Harry Bridges Plaza (Ferry Building)
50
414
Customer
94124
144014
198775
570
2/28/2014 23:20
2nd at South Park
64
2/28/2014 23:30
Townsend at 7th
65
577
Subscriber
94107
144015 rows × 11 columns
In [18]:
from afdata import pattern_mining
journeys = df[['Start Station', 'End Station']]
In [19]:
pattern_mining.get_frequent_itemsets(journeys, 0.2)
Out[19]:
([], [])
In [ ]:
Content source: aaronfalloon/afdata
Similar notebooks: