-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtools.py
More file actions
36 lines (30 loc) · 755 Bytes
/
tools.py
File metadata and controls
36 lines (30 loc) · 755 Bytes
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
import matplotlib.pyplot as plt
import csv
def ReadData(filename='./showcases.2011.csv'):
"""Reads a CSV file of data.
Args:
filename: string filename
Returns: sequence of (price1 price2 bid1 bid2 diff1 diff2) tuples
"""
fp = open(filename)
reader = csv.reader(fp)
res = []
for t in reader:
_heading = t[0]
data = t[1:]
try:
data = [int(x) for x in data]
# print heading, data[0], len(data)
res.append(data)
except ValueError:
pass
fp.close()
return zip(*res)
def Plot(p):
x = []
prob = []
for _x, _prob in sorted(p.Items()):
x.append(_x)
prob.append(_prob)
plt.plot(x, prob)
plt.show()