In [1]:
print("Hello,World")
Hello,World
In [5]:
for i in range(3):
print(i)
0
1
2
In [6]:
for i in range(20):
if i < 10:
print("%d - Less than 10" %(i))
elif i==10:
print("%d - 10 exactly" %(i))
else:
print("%d - Greater than 10" %(i))
0 - Less than 10
1 - Less than 10
2 - Less than 10
3 - Less than 10
4 - Less than 10
5 - Less than 10
6 - Less than 10
7 - Less than 10
8 - Less than 10
9 - Less than 10
10 - 10 exactly
11 - Greater than 10
12 - Greater than 10
13 - Greater than 10
14 - Greater than 10
15 - Greater than 10
16 - Greater than 10
17 - Greater than 10
18 - Greater than 10
19 - Greater than 10
In [12]:
i=10
j=20
print("%d is half of %d" %(i,j))
print("%d is half of 20" %i)
10 is half of 20
10 is half of 20
In [13]:
def hello():
print("Hello, World")
In [14]:
hello()
Hello, World
In [15]:
def hello(name):
print("Hello,%s" %(name))
In [16]:
hello("NYU student")
Hello,NYU student
In [17]:
def hello(name="NYU student"):
print("Hello,%s" %(name))
In [18]:
hello()
hello("NYU Tandon ECE student")
Hello,NYU student
Hello,NYU Tandon ECE student
In [19]:
animals=[]
animals.append("bear")
animals.append("lion")
animals.append("monkey")
animals.append("Jiadong Unicorn")
print(animals)
['bear', 'lion', 'monkey', 'Jiadong Unicorn']
In [20]:
print(animals[3])
Jiadong Unicorn
In [21]:
for animal in animals:
print(animal)
bear
lion
monkey
Jiadong Unicorn
In [22]:
a = animals.pop()
print(a)
print(animals)
Jiadong Unicorn
['bear', 'lion', 'monkey']
In [23]:
a = animals.pop(1)
print(a)
print(animals)
lion
['bear', 'monkey']
In [24]:
animals.append("bear")
print(animals)
animals.count("bear")
['bear', 'monkey', 'bear']
Out[24]:
2
In [25]:
animals.sort()
print(animals)
['bear', 'bear', 'monkey']
In [33]:
animals = ["bear","lion","monkey","Jiadong Unicorn", "bear"]
new = [a for a in animals if a!="bear"]
print(new)
['lion', 'monkey', 'Jiadong Unicorn']
In [37]:
new1=[a.upper() for a in new]
print(new1)
new2=[a.upper() for a in animals]
print(new2)
new3=[a.upper() for a in animals if a!="bear"]
print(new3)
['LION', 'MONKEY', 'JIADONG UNICORN']
['BEAR', 'LION', 'MONKEY', 'JIADONG UNICORN', 'BEAR']
['LION', 'MONKEY', 'JIADONG UNICORN']
In [38]:
import random
In [39]:
random.randint(0,10)
Out[39]:
7
In [42]:
import numpy as np
print(np.power(2,2))
print(np.power(2,3))
4
8
In [43]:
from random import *
randint(0,10)
Out[43]:
0
this is not recommended due to the possibility of naming collision.
In [45]:
import numpy as np
import matplotlib.pyplot as plt
X=np.linspace(-np.pi,np.pi,256,endpoint=True)
C,S=np.cos(X),np.sin(X)
plt.plot(X,C)
plt.plot(X,S)
plt.show()
In [1]:
import csv
filename='smalldata.csv'
with open(filename, 'r') as csvfile:
filereader = csv.reader(csvfile,delimiter=',')
for row in filereader:
print(', '.join(row))
tripduration, starttime, stoptime, start station id, start station name, start station latitude, start station longitude, end station id, end station name, end station latitude, end station longitude, bikeid, usertype, birth year, gender
1491, 3/1/2016 06:52:42, 3/1/2016 07:17:33, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 427, Bus Slip & State St, 40.701907, -74.013942, 23914, Subscriber, 1982, 1
1044, 3/1/2016 07:05:50, 3/1/2016 07:23:15, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 254, W 11 St & 6 Ave, 40.73532427, -73.99800419, 23697, Subscriber, 1978, 1
714, 3/1/2016 07:15:05, 3/1/2016 07:26:59, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 493, W 45 St & 6 Ave, 40.7568001, -73.98291153, 21447, Subscriber, 1960, 2
329, 3/1/2016 07:26:04, 3/1/2016 07:31:34, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 478, 11 Ave & W 41 St, 40.76030096, -73.99884222, 22351, Subscriber, 1986, 1
1871, 3/1/2016 07:31:30, 3/1/2016 08:02:41, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 151, Cleveland Pl & Spring St, 40.722103786686034, -73.99724900722504, 20985, Subscriber, 1978, 1
859, 3/1/2016 07:33:46, 3/1/2016 07:48:06, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 520, W 52 St & 5 Ave, 40.75992262, -73.97648516, 15557, Subscriber, 1975, 1
538, 3/1/2016 07:36:31, 3/1/2016 07:45:29, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 533, Broadway & W 39 St, 40.75299641, -73.98721619, 22638, Subscriber, 1993, 1
1255, 3/1/2016 07:38:14, 3/1/2016 07:59:10, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 426, West St & Chambers St, 40.71754834, -74.01322069, 23864, Subscriber, 1988, 2
1216, 3/1/2016 07:57:05, 3/1/2016 08:17:21, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 325, E 19 St & 3 Ave, 40.73624527, -73.98473765, 17821, Subscriber, 1982, 1
280, 3/1/2016 08:01:30, 3/1/2016 08:06:11, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 500, Broadway & W 51 St, 40.76228826, -73.98336183, 21458, Subscriber, 1982, 1
442, 3/1/2016 08:02:48, 3/1/2016 08:10:10, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 173, Broadway & W 49 St, 40.76068327096592, -73.9845272898674, 17376, Subscriber, 1983, 1
614, 3/1/2016 08:13:59, 3/1/2016 08:24:14, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 522, E 51 St & Lexington Ave, 40.75714758, -73.97207836, 23644, Subscriber, 1977, 1
1116, 3/1/2016 08:21:44, 3/1/2016 08:40:21, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 358, Christopher St & Greenwich St, 40.73291553, -74.00711384, 20242, Subscriber, 1985, 1
727, 3/1/2016 08:31:45, 3/1/2016 08:43:52, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 225, W 14 St & The High Line, 40.74195138, -74.00803013, 17166, Subscriber, 1973, 1
1355, 3/1/2016 08:36:10, 3/1/2016 08:58:46, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 336, Sullivan St & Washington Sq, 40.73047747, -73.99906065, 20181, Subscriber, 1979, 1
905, 3/1/2016 08:41:07, 3/1/2016 08:56:13, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 463, 9 Ave & W 16 St, 40.74206539, -74.00443172, 21136, Subscriber, 1975, 1
676, 3/1/2016 08:41:49, 3/1/2016 08:53:05, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 490, 8 Ave & W 33 St, 40.751551, -73.993934, 16423, Subscriber, 1984, 1
943, 3/1/2016 08:42:34, 3/1/2016 08:58:18, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 485, W 37 St & 5 Ave, 40.75038009, -73.98338988, 19506, Subscriber, 1976, 2
583, 3/1/2016 08:44:44, 3/1/2016 08:54:28, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 522, E 51 St & Lexington Ave, 40.75714758, -73.97207836, 16032, Subscriber, 1982, 2
578, 3/1/2016 08:47:17, 3/1/2016 08:56:55, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 359, E 47 St & Park Ave, 40.75510267, -73.97498696, 16445, Subscriber, 1975, 1
711, 3/1/2016 08:47:44, 3/1/2016 08:59:36, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 465, Broadway & W 41 St, 40.75513557, -73.98658032, 22240, Subscriber, 1956, 1
789, 3/1/2016 08:48:46, 3/1/2016 09:01:56, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 267, Broadway & W 36 St, 40.75097711, -73.98765428, 23445, Subscriber, 1964, 1
630, 3/1/2016 09:15:14, 3/1/2016 09:25:44, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 520, W 52 St & 5 Ave, 40.75992262, -73.97648516, 15463, Subscriber, 1960, 1
1324, 3/1/2016 09:21:56, 3/1/2016 09:44:00, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 329, Greenwich St & N Moore St, 40.72043411, -74.01020609, 22674, Subscriber, 1992, 1
1010, 3/1/2016 09:25:33, 3/1/2016 09:42:24, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 127, Barrow St & Hudson St, 40.73172428, -74.00674436, 23269, Subscriber, 1988, 1
1129, 3/1/2016 09:28:23, 3/1/2016 09:47:13, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 500, Broadway & W 51 St, 40.76228826, -73.98336183, 23228, Subscriber, 1947, 1
1324, 3/1/2016 09:49:17, 3/1/2016 10:11:22, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 518, E 39 St & 2 Ave, 40.74780373, -73.9734419, 22164, Subscriber, 1962, 1
455, 3/1/2016 09:50:27, 3/1/2016 09:58:03, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 525, W 34 St & 11 Ave, 40.75594159, -74.0021163, 16131, Subscriber, 1974, 1
385, 3/1/2016 09:55:30, 3/1/2016 10:01:56, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 2021, W 45 St & 8 Ave, 40.75929124, -73.98859651, 22024, Subscriber, 1986, 2
769, 3/1/2016 10:02:32, 3/1/2016 10:15:22, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 519, Pershing Square North, 40.751873, -73.977706, 18432, Subscriber, 1981, 2
636, 3/1/2016 10:02:39, 3/1/2016 10:13:16, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 489, 10 Ave & W 28 St, 40.75066386, -74.00176802, 20091, Subscriber, 1987, 1
339, 3/1/2016 10:06:43, 3/1/2016 10:12:23, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 488, W 39 St & 9 Ave, 40.75645824, -73.99372222, 18731, Subscriber, 1986, 1
1290, 3/1/2016 10:07:44, 3/1/2016 10:29:15, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 517, Pershing Square South, 40.751581, -73.97791, 21040, Subscriber, 1972, 2
1431, 3/1/2016 10:19:44, 3/1/2016 10:43:35, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 358, Christopher St & Greenwich St, 40.73291553, -74.00711384, 22980, Subscriber, 1974, 1
1442, 3/1/2016 10:39:50, 3/1/2016 11:03:53, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 325, E 19 St & 3 Ave, 40.73624527, -73.98473765, 23032, Subscriber, 1983, 2
922, 3/1/2016 11:37:30, 3/1/2016 11:52:53, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 459, W 20 St & 11 Ave, 40.746745, -74.007756, 24273, Customer, , 0
265, 3/1/2016 12:04:36, 3/1/2016 12:09:01, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 450, W 49 St & 8 Ave, 40.76227205, -73.98788205, 20958, Subscriber, 1955, 1
407, 3/1/2016 12:28:33, 3/1/2016 12:35:21, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 525, W 34 St & 11 Ave, 40.75594159, -74.0021163, 20329, Subscriber, 1969, 1
602, 3/1/2016 13:08:20, 3/1/2016 13:18:23, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 499, Broadway & W 60 St, 40.76915505, -73.98191841, 22584, Subscriber, 1967, 1
469, 3/1/2016 13:47:33, 3/1/2016 13:55:22, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 525, W 34 St & 11 Ave, 40.75594159, -74.0021163, 23445, Subscriber, 1984, 1
276, 3/1/2016 13:49:54, 3/1/2016 13:54:31, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 514, 12 Ave & W 40 St, 40.76087502, -74.00277668, 15267, Subscriber, 1978, 1
903, 3/1/2016 13:50:46, 3/1/2016 14:05:49, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 490, 8 Ave & W 33 St, 40.751551, -73.993934, 16861, Subscriber, 1960, 2
569, 3/1/2016 13:56:59, 3/1/2016 14:06:29, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 447, 8 Ave & W 52 St, 40.76370739, -73.9851615, 17354, Subscriber, 1947, 1
1829, 3/1/2016 14:08:30, 3/1/2016 14:39:00, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 3145, E 84 St & Park Ave, 40.77862688, -73.95772073, 18761, Subscriber, 1962, 1
984, 3/1/2016 14:12:23, 3/1/2016 14:28:48, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 509, 9 Ave & W 22 St, 40.7454973, -74.00197139, 19877, Subscriber, 1967, 1
1095, 3/1/2016 14:20:49, 3/1/2016 14:39:05, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 3224, W 13 St & Hudson St, 40.73997354103409, -74.00513872504234, 22174, Subscriber, 1979, 1
597, 3/1/2016 15:29:10, 3/1/2016 15:39:07, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 529, W 42 St & 8 Ave, 40.7575699, -73.99098507, 16131, Subscriber, 1970, 1
318, 3/1/2016 15:44:47, 3/1/2016 15:50:06, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 450, W 49 St & 8 Ave, 40.76227205, -73.98788205, 20114, Subscriber, 1970, 1
625, 3/1/2016 15:56:02, 3/1/2016 16:06:27, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 72, W 52 St & 11 Ave, 40.76727216, -73.99392888, 18185, Subscriber, 1953, 2
In [2]:
filename='smalldata.csv'
with open(filename, 'r') as csvfile:
filereader = csv.reader(csvfile,delimiter=',')
for row in filereader:
print(row[1])
starttime
3/1/2016 06:52:42
3/1/2016 07:05:50
3/1/2016 07:15:05
3/1/2016 07:26:04
3/1/2016 07:31:30
3/1/2016 07:33:46
3/1/2016 07:36:31
3/1/2016 07:38:14
3/1/2016 07:57:05
3/1/2016 08:01:30
3/1/2016 08:02:48
3/1/2016 08:13:59
3/1/2016 08:21:44
3/1/2016 08:31:45
3/1/2016 08:36:10
3/1/2016 08:41:07
3/1/2016 08:41:49
3/1/2016 08:42:34
3/1/2016 08:44:44
3/1/2016 08:47:17
3/1/2016 08:47:44
3/1/2016 08:48:46
3/1/2016 09:15:14
3/1/2016 09:21:56
3/1/2016 09:25:33
3/1/2016 09:28:23
3/1/2016 09:49:17
3/1/2016 09:50:27
3/1/2016 09:55:30
3/1/2016 10:02:32
3/1/2016 10:02:39
3/1/2016 10:06:43
3/1/2016 10:07:44
3/1/2016 10:19:44
3/1/2016 10:39:50
3/1/2016 11:37:30
3/1/2016 12:04:36
3/1/2016 12:28:33
3/1/2016 13:08:20
3/1/2016 13:47:33
3/1/2016 13:49:54
3/1/2016 13:50:46
3/1/2016 13:56:59
3/1/2016 14:08:30
3/1/2016 14:12:23
3/1/2016 14:20:49
3/1/2016 15:29:10
3/1/2016 15:44:47
3/1/2016 15:56:02
In [4]:
durations = []
filename = 'smalldata.csv'
with open(filename,'r') as csvfile:
filereader = csv.reader(csvfile,delimiter=',')
header = next(filereader)
for row in filereader:
durations.append(int(row[0]))
print(durations)
[1491, 1044, 714, 329, 1871, 859, 538, 1255, 1216, 280, 442, 614, 1116, 727, 1355, 905, 676, 943, 583, 578, 711, 789, 630, 1324, 1010, 1129, 1324, 455, 385, 769, 636, 339, 1290, 1431, 1442, 922, 265, 407, 602, 469, 276, 903, 569, 1829, 984, 1095, 597, 318, 625]
In [5]:
import pandas as pd
filename='smalldata.csv'
df=pd.read_csv(filename,sep=',')
print(df)
tripduration starttime stoptime start station id \
0 1491 3/1/2016 06:52:42 3/1/2016 07:17:33 72
1 1044 3/1/2016 07:05:50 3/1/2016 07:23:15 72
2 714 3/1/2016 07:15:05 3/1/2016 07:26:59 72
3 329 3/1/2016 07:26:04 3/1/2016 07:31:34 72
4 1871 3/1/2016 07:31:30 3/1/2016 08:02:41 72
5 859 3/1/2016 07:33:46 3/1/2016 07:48:06 72
6 538 3/1/2016 07:36:31 3/1/2016 07:45:29 72
7 1255 3/1/2016 07:38:14 3/1/2016 07:59:10 72
8 1216 3/1/2016 07:57:05 3/1/2016 08:17:21 72
9 280 3/1/2016 08:01:30 3/1/2016 08:06:11 72
10 442 3/1/2016 08:02:48 3/1/2016 08:10:10 72
11 614 3/1/2016 08:13:59 3/1/2016 08:24:14 72
12 1116 3/1/2016 08:21:44 3/1/2016 08:40:21 72
13 727 3/1/2016 08:31:45 3/1/2016 08:43:52 72
14 1355 3/1/2016 08:36:10 3/1/2016 08:58:46 72
15 905 3/1/2016 08:41:07 3/1/2016 08:56:13 72
16 676 3/1/2016 08:41:49 3/1/2016 08:53:05 72
17 943 3/1/2016 08:42:34 3/1/2016 08:58:18 72
18 583 3/1/2016 08:44:44 3/1/2016 08:54:28 72
19 578 3/1/2016 08:47:17 3/1/2016 08:56:55 72
20 711 3/1/2016 08:47:44 3/1/2016 08:59:36 72
21 789 3/1/2016 08:48:46 3/1/2016 09:01:56 72
22 630 3/1/2016 09:15:14 3/1/2016 09:25:44 72
23 1324 3/1/2016 09:21:56 3/1/2016 09:44:00 72
24 1010 3/1/2016 09:25:33 3/1/2016 09:42:24 72
25 1129 3/1/2016 09:28:23 3/1/2016 09:47:13 72
26 1324 3/1/2016 09:49:17 3/1/2016 10:11:22 72
27 455 3/1/2016 09:50:27 3/1/2016 09:58:03 72
28 385 3/1/2016 09:55:30 3/1/2016 10:01:56 72
29 769 3/1/2016 10:02:32 3/1/2016 10:15:22 72
30 636 3/1/2016 10:02:39 3/1/2016 10:13:16 72
31 339 3/1/2016 10:06:43 3/1/2016 10:12:23 72
32 1290 3/1/2016 10:07:44 3/1/2016 10:29:15 72
33 1431 3/1/2016 10:19:44 3/1/2016 10:43:35 72
34 1442 3/1/2016 10:39:50 3/1/2016 11:03:53 72
35 922 3/1/2016 11:37:30 3/1/2016 11:52:53 72
36 265 3/1/2016 12:04:36 3/1/2016 12:09:01 72
37 407 3/1/2016 12:28:33 3/1/2016 12:35:21 72
38 602 3/1/2016 13:08:20 3/1/2016 13:18:23 72
39 469 3/1/2016 13:47:33 3/1/2016 13:55:22 72
40 276 3/1/2016 13:49:54 3/1/2016 13:54:31 72
41 903 3/1/2016 13:50:46 3/1/2016 14:05:49 72
42 569 3/1/2016 13:56:59 3/1/2016 14:06:29 72
43 1829 3/1/2016 14:08:30 3/1/2016 14:39:00 72
44 984 3/1/2016 14:12:23 3/1/2016 14:28:48 72
45 1095 3/1/2016 14:20:49 3/1/2016 14:39:05 72
46 597 3/1/2016 15:29:10 3/1/2016 15:39:07 72
47 318 3/1/2016 15:44:47 3/1/2016 15:50:06 72
48 625 3/1/2016 15:56:02 3/1/2016 16:06:27 72
start station name start station latitude start station longitude \
0 W 52 St & 11 Ave 40.767272 -73.993929
1 W 52 St & 11 Ave 40.767272 -73.993929
2 W 52 St & 11 Ave 40.767272 -73.993929
3 W 52 St & 11 Ave 40.767272 -73.993929
4 W 52 St & 11 Ave 40.767272 -73.993929
5 W 52 St & 11 Ave 40.767272 -73.993929
6 W 52 St & 11 Ave 40.767272 -73.993929
7 W 52 St & 11 Ave 40.767272 -73.993929
8 W 52 St & 11 Ave 40.767272 -73.993929
9 W 52 St & 11 Ave 40.767272 -73.993929
10 W 52 St & 11 Ave 40.767272 -73.993929
11 W 52 St & 11 Ave 40.767272 -73.993929
12 W 52 St & 11 Ave 40.767272 -73.993929
13 W 52 St & 11 Ave 40.767272 -73.993929
14 W 52 St & 11 Ave 40.767272 -73.993929
15 W 52 St & 11 Ave 40.767272 -73.993929
16 W 52 St & 11 Ave 40.767272 -73.993929
17 W 52 St & 11 Ave 40.767272 -73.993929
18 W 52 St & 11 Ave 40.767272 -73.993929
19 W 52 St & 11 Ave 40.767272 -73.993929
20 W 52 St & 11 Ave 40.767272 -73.993929
21 W 52 St & 11 Ave 40.767272 -73.993929
22 W 52 St & 11 Ave 40.767272 -73.993929
23 W 52 St & 11 Ave 40.767272 -73.993929
24 W 52 St & 11 Ave 40.767272 -73.993929
25 W 52 St & 11 Ave 40.767272 -73.993929
26 W 52 St & 11 Ave 40.767272 -73.993929
27 W 52 St & 11 Ave 40.767272 -73.993929
28 W 52 St & 11 Ave 40.767272 -73.993929
29 W 52 St & 11 Ave 40.767272 -73.993929
30 W 52 St & 11 Ave 40.767272 -73.993929
31 W 52 St & 11 Ave 40.767272 -73.993929
32 W 52 St & 11 Ave 40.767272 -73.993929
33 W 52 St & 11 Ave 40.767272 -73.993929
34 W 52 St & 11 Ave 40.767272 -73.993929
35 W 52 St & 11 Ave 40.767272 -73.993929
36 W 52 St & 11 Ave 40.767272 -73.993929
37 W 52 St & 11 Ave 40.767272 -73.993929
38 W 52 St & 11 Ave 40.767272 -73.993929
39 W 52 St & 11 Ave 40.767272 -73.993929
40 W 52 St & 11 Ave 40.767272 -73.993929
41 W 52 St & 11 Ave 40.767272 -73.993929
42 W 52 St & 11 Ave 40.767272 -73.993929
43 W 52 St & 11 Ave 40.767272 -73.993929
44 W 52 St & 11 Ave 40.767272 -73.993929
45 W 52 St & 11 Ave 40.767272 -73.993929
46 W 52 St & 11 Ave 40.767272 -73.993929
47 W 52 St & 11 Ave 40.767272 -73.993929
48 W 52 St & 11 Ave 40.767272 -73.993929
end station id end station name end station latitude \
0 427 Bus Slip & State St 40.701907
1 254 W 11 St & 6 Ave 40.735324
2 493 W 45 St & 6 Ave 40.756800
3 478 11 Ave & W 41 St 40.760301
4 151 Cleveland Pl & Spring St 40.722104
5 520 W 52 St & 5 Ave 40.759923
6 533 Broadway & W 39 St 40.752996
7 426 West St & Chambers St 40.717548
8 325 E 19 St & 3 Ave 40.736245
9 500 Broadway & W 51 St 40.762288
10 173 Broadway & W 49 St 40.760683
11 522 E 51 St & Lexington Ave 40.757148
12 358 Christopher St & Greenwich St 40.732916
13 225 W 14 St & The High Line 40.741951
14 336 Sullivan St & Washington Sq 40.730477
15 463 9 Ave & W 16 St 40.742065
16 490 8 Ave & W 33 St 40.751551
17 485 W 37 St & 5 Ave 40.750380
18 522 E 51 St & Lexington Ave 40.757148
19 359 E 47 St & Park Ave 40.755103
20 465 Broadway & W 41 St 40.755136
21 267 Broadway & W 36 St 40.750977
22 520 W 52 St & 5 Ave 40.759923
23 329 Greenwich St & N Moore St 40.720434
24 127 Barrow St & Hudson St 40.731724
25 500 Broadway & W 51 St 40.762288
26 518 E 39 St & 2 Ave 40.747804
27 525 W 34 St & 11 Ave 40.755942
28 2021 W 45 St & 8 Ave 40.759291
29 519 Pershing Square North 40.751873
30 489 10 Ave & W 28 St 40.750664
31 488 W 39 St & 9 Ave 40.756458
32 517 Pershing Square South 40.751581
33 358 Christopher St & Greenwich St 40.732916
34 325 E 19 St & 3 Ave 40.736245
35 459 W 20 St & 11 Ave 40.746745
36 450 W 49 St & 8 Ave 40.762272
37 525 W 34 St & 11 Ave 40.755942
38 499 Broadway & W 60 St 40.769155
39 525 W 34 St & 11 Ave 40.755942
40 514 12 Ave & W 40 St 40.760875
41 490 8 Ave & W 33 St 40.751551
42 447 8 Ave & W 52 St 40.763707
43 3145 E 84 St & Park Ave 40.778627
44 509 9 Ave & W 22 St 40.745497
45 3224 W 13 St & Hudson St 40.739974
46 529 W 42 St & 8 Ave 40.757570
47 450 W 49 St & 8 Ave 40.762272
48 72 W 52 St & 11 Ave 40.767272
end station longitude bikeid usertype birth year gender
0 -74.013942 23914 Subscriber 1982.0 1
1 -73.998004 23697 Subscriber 1978.0 1
2 -73.982912 21447 Subscriber 1960.0 2
3 -73.998842 22351 Subscriber 1986.0 1
4 -73.997249 20985 Subscriber 1978.0 1
5 -73.976485 15557 Subscriber 1975.0 1
6 -73.987216 22638 Subscriber 1993.0 1
7 -74.013221 23864 Subscriber 1988.0 2
8 -73.984738 17821 Subscriber 1982.0 1
9 -73.983362 21458 Subscriber 1982.0 1
10 -73.984527 17376 Subscriber 1983.0 1
11 -73.972078 23644 Subscriber 1977.0 1
12 -74.007114 20242 Subscriber 1985.0 1
13 -74.008030 17166 Subscriber 1973.0 1
14 -73.999061 20181 Subscriber 1979.0 1
15 -74.004432 21136 Subscriber 1975.0 1
16 -73.993934 16423 Subscriber 1984.0 1
17 -73.983390 19506 Subscriber 1976.0 2
18 -73.972078 16032 Subscriber 1982.0 2
19 -73.974987 16445 Subscriber 1975.0 1
20 -73.986580 22240 Subscriber 1956.0 1
21 -73.987654 23445 Subscriber 1964.0 1
22 -73.976485 15463 Subscriber 1960.0 1
23 -74.010206 22674 Subscriber 1992.0 1
24 -74.006744 23269 Subscriber 1988.0 1
25 -73.983362 23228 Subscriber 1947.0 1
26 -73.973442 22164 Subscriber 1962.0 1
27 -74.002116 16131 Subscriber 1974.0 1
28 -73.988597 22024 Subscriber 1986.0 2
29 -73.977706 18432 Subscriber 1981.0 2
30 -74.001768 20091 Subscriber 1987.0 1
31 -73.993722 18731 Subscriber 1986.0 1
32 -73.977910 21040 Subscriber 1972.0 2
33 -74.007114 22980 Subscriber 1974.0 1
34 -73.984738 23032 Subscriber 1983.0 2
35 -74.007756 24273 Customer NaN 0
36 -73.987882 20958 Subscriber 1955.0 1
37 -74.002116 20329 Subscriber 1969.0 1
38 -73.981918 22584 Subscriber 1967.0 1
39 -74.002116 23445 Subscriber 1984.0 1
40 -74.002777 15267 Subscriber 1978.0 1
41 -73.993934 16861 Subscriber 1960.0 2
42 -73.985162 17354 Subscriber 1947.0 1
43 -73.957721 18761 Subscriber 1962.0 1
44 -74.001971 19877 Subscriber 1967.0 1
45 -74.005139 22174 Subscriber 1979.0 1
46 -73.990985 16131 Subscriber 1970.0 1
47 -73.987882 20114 Subscriber 1970.0 1
48 -73.993929 18185 Subscriber 1953.0 2
In [6]:
df.columns
Out[6]:
Index(['tripduration', 'starttime', 'stoptime', 'start station id',
'start station name', 'start station latitude',
'start station longitude', 'end station id', 'end station name',
'end station latitude', 'end station longitude', 'bikeid', 'usertype',
'birth year', 'gender'],
dtype='object')
In [7]:
df.head()
Out[7]:
tripduration
starttime
stoptime
start station id
start station name
start station latitude
start station longitude
end station id
end station name
end station latitude
end station longitude
bikeid
usertype
birth year
gender
0
1491
3/1/2016 06:52:42
3/1/2016 07:17:33
72
W 52 St & 11 Ave
40.767272
-73.993929
427
Bus Slip & State St
40.701907
-74.013942
23914
Subscriber
1982.0
1
1
1044
3/1/2016 07:05:50
3/1/2016 07:23:15
72
W 52 St & 11 Ave
40.767272
-73.993929
254
W 11 St & 6 Ave
40.735324
-73.998004
23697
Subscriber
1978.0
1
2
714
3/1/2016 07:15:05
3/1/2016 07:26:59
72
W 52 St & 11 Ave
40.767272
-73.993929
493
W 45 St & 6 Ave
40.756800
-73.982912
21447
Subscriber
1960.0
2
3
329
3/1/2016 07:26:04
3/1/2016 07:31:34
72
W 52 St & 11 Ave
40.767272
-73.993929
478
11 Ave & W 41 St
40.760301
-73.998842
22351
Subscriber
1986.0
1
4
1871
3/1/2016 07:31:30
3/1/2016 08:02:41
72
W 52 St & 11 Ave
40.767272
-73.993929
151
Cleveland Pl & Spring St
40.722104
-73.997249
20985
Subscriber
1978.0
1
In [8]:
df.tail()
Out[8]:
tripduration
starttime
stoptime
start station id
start station name
start station latitude
start station longitude
end station id
end station name
end station latitude
end station longitude
bikeid
usertype
birth year
gender
44
984
3/1/2016 14:12:23
3/1/2016 14:28:48
72
W 52 St & 11 Ave
40.767272
-73.993929
509
9 Ave & W 22 St
40.745497
-74.001971
19877
Subscriber
1967.0
1
45
1095
3/1/2016 14:20:49
3/1/2016 14:39:05
72
W 52 St & 11 Ave
40.767272
-73.993929
3224
W 13 St & Hudson St
40.739974
-74.005139
22174
Subscriber
1979.0
1
46
597
3/1/2016 15:29:10
3/1/2016 15:39:07
72
W 52 St & 11 Ave
40.767272
-73.993929
529
W 42 St & 8 Ave
40.757570
-73.990985
16131
Subscriber
1970.0
1
47
318
3/1/2016 15:44:47
3/1/2016 15:50:06
72
W 52 St & 11 Ave
40.767272
-73.993929
450
W 49 St & 8 Ave
40.762272
-73.987882
20114
Subscriber
1970.0
1
48
625
3/1/2016 15:56:02
3/1/2016 16:06:27
72
W 52 St & 11 Ave
40.767272
-73.993929
72
W 52 St & 11 Ave
40.767272
-73.993929
18185
Subscriber
1953.0
2
In [9]:
df.tail(3)
Out[9]:
tripduration
starttime
stoptime
start station id
start station name
start station latitude
start station longitude
end station id
end station name
end station latitude
end station longitude
bikeid
usertype
birth year
gender
46
597
3/1/2016 15:29:10
3/1/2016 15:39:07
72
W 52 St & 11 Ave
40.767272
-73.993929
529
W 42 St & 8 Ave
40.757570
-73.990985
16131
Subscriber
1970.0
1
47
318
3/1/2016 15:44:47
3/1/2016 15:50:06
72
W 52 St & 11 Ave
40.767272
-73.993929
450
W 49 St & 8 Ave
40.762272
-73.987882
20114
Subscriber
1970.0
1
48
625
3/1/2016 15:56:02
3/1/2016 16:06:27
72
W 52 St & 11 Ave
40.767272
-73.993929
72
W 52 St & 11 Ave
40.767272
-73.993929
18185
Subscriber
1953.0
2
In [10]:
df.describe()
Out[10]:
tripduration
start station id
start station latitude
start station longitude
end station id
end station latitude
end station longitude
bikeid
birth year
gender
count
49.000000
49.0
49.000000
49.000000
49.000000
49.000000
49.000000
49.000000
48.000000
49.000000
mean
837.979592
72.0
40.767272
-73.993929
568.285714
40.749500
-73.991735
20268.163265
1974.291667
1.183673
std
409.055084
0.0
0.000000
0.000000
602.964275
0.014781
0.012731
2768.512908
11.573922
0.441280
min
265.000000
72.0
40.767272
-73.993929
72.000000
40.701907
-74.013942
15267.000000
1947.000000
0.000000
25%
569.000000
72.0
40.767272
-73.993929
358.000000
40.741951
-74.002116
17821.000000
1967.000000
1.000000
50%
727.000000
72.0
40.767272
-73.993929
488.000000
40.752996
-73.990985
20958.000000
1976.500000
1.000000
75%
1116.000000
72.0
40.767272
-73.993929
519.000000
40.759923
-73.983362
22638.000000
1983.000000
1.000000
max
1871.000000
72.0
40.767272
-73.993929
3224.000000
40.778627
-73.957721
24273.000000
1993.000000
2.000000
In [11]:
for index,row in df.iterrows():
print(index,row['starttime'])
0 3/1/2016 06:52:42
1 3/1/2016 07:05:50
2 3/1/2016 07:15:05
3 3/1/2016 07:26:04
4 3/1/2016 07:31:30
5 3/1/2016 07:33:46
6 3/1/2016 07:36:31
7 3/1/2016 07:38:14
8 3/1/2016 07:57:05
9 3/1/2016 08:01:30
10 3/1/2016 08:02:48
11 3/1/2016 08:13:59
12 3/1/2016 08:21:44
13 3/1/2016 08:31:45
14 3/1/2016 08:36:10
15 3/1/2016 08:41:07
16 3/1/2016 08:41:49
17 3/1/2016 08:42:34
18 3/1/2016 08:44:44
19 3/1/2016 08:47:17
20 3/1/2016 08:47:44
21 3/1/2016 08:48:46
22 3/1/2016 09:15:14
23 3/1/2016 09:21:56
24 3/1/2016 09:25:33
25 3/1/2016 09:28:23
26 3/1/2016 09:49:17
27 3/1/2016 09:50:27
28 3/1/2016 09:55:30
29 3/1/2016 10:02:32
30 3/1/2016 10:02:39
31 3/1/2016 10:06:43
32 3/1/2016 10:07:44
33 3/1/2016 10:19:44
34 3/1/2016 10:39:50
35 3/1/2016 11:37:30
36 3/1/2016 12:04:36
37 3/1/2016 12:28:33
38 3/1/2016 13:08:20
39 3/1/2016 13:47:33
40 3/1/2016 13:49:54
41 3/1/2016 13:50:46
42 3/1/2016 13:56:59
43 3/1/2016 14:08:30
44 3/1/2016 14:12:23
45 3/1/2016 14:20:49
46 3/1/2016 15:29:10
47 3/1/2016 15:44:47
48 3/1/2016 15:56:02
In [ ]:
Content source: LvDQ/NYU_workshop
Similar notebooks: