-
Notifications
You must be signed in to change notification settings - Fork 0
/
hehe.py
154 lines (116 loc) · 3.18 KB
/
hehe.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#coding=utf-8
'''
from theano import function, config, shared, sandbox, tensor, Out
import numpy
import time
import theano
import theano.tensor as T
import matplotlib.pyplot as plt
from matplotlib.pyplot import *
import numpy as np
#for idx,color in enumerate("rgbyck"):
#plt.subplot(231+idx,axisbg=color)
plt.figure(1)
plt.figure(2)
ax1=plt.subplot(211)
ax2=plt.subplot(212)
x=np.linspace(0,3,100)
for i in range(5):
plt.figure(1)
plt.plot(x,np.exp(i*x/3))
plt.sca(ax1)
plt.plot(x,np.sin(i*x))
plt.sca(ax2)
plt.plot(x,np.cos(i*x))
plt.figure(3)
plt.plot([1,2],[1,3])
title('sh')
xlabel('sfaf')
ylabel('y')
savefig('demo.jpg')
import matplotlib.pyplot as plt
# 1D data
x = [1,2,3,4,5]
y = [2.3,3.4,1.2,6.6,7.0]
plt.figure(figsize=(12,6))
plt.subplot(231)
plt.plot(x,y)
plt.title("plot")
plt.subplot(232)
plt.scatter(x, y)
plt.title("scatter")
plt.subplot(233)
plt.pie(y)
plt.title("pie")
plt.subplot(234)
plt.bar(x, y)
plt.title("bar")
# 2D data
import numpy as np
delta = 0.025
x = y = np.arange(-3.0, 3.0, delta)
X, Y = np.meshgrid(x, y)
Z = Y**2 + X**2
plt.subplot(235)
plt.contour(X,Y,Z)
plt.colorbar()
plt.title("contour")
plt.show()
'''
"""
import MySQLdb
import numpy
conn=MySQLdb.connect(host='localhost',user='root237',passwd='root237',db='test',port=3306)
#conn1=MySQLdb.connect(host='localhost',user='root237',passwd='root237',db='test',port=3306)
cur=conn.cursor()
#co=conn1.cursor()
d=cur.execute("select distinct * from stock_list")
print d
c=cur.fetchall()
print c
n=0
for i in c:
'''
try:
cur.execute("create table temp as (select * from `%s` order by date_time asc)"%str.lower(list(i)[0]))
cur.execute("drop table `%s`"%str.lower(list(i)[0]))
cur.execute("alter table temp rename to `%s`"%str.lower(list(i)[0]))
conn.commit()
n+=1
except:
print 'fail'
'''
try:
#cur.execute("select max(date_time) from `%s`"%str.lower(list(i)[0]))
#cur.execute("alter table `%s` add primary key(date_time)"%str.lower(list(i)[0]))
cur.execute("alter table `%s` modify open double "%str.lower(list(i)[0]))
cur.execute("alter table `%s` modify high double "%str.lower(list(i)[0]))
cur.execute("alter table `%s` modify low double "%str.lower(list(i)[0]))
cur.execute("alter table `%s` modify close double "%str.lower(list(i)[0]))
cur.execute("alter table `%s` modify volume double "%str.lower(list(i)[0]))
cur.execute("alter table `%s` modify amt double "%str.lower(list(i)[0]))
conn.commit()
#b=cur.fetchall()
#print b,i,'a'
'''
co.execute("select * from `%s`"%str.lower(list(i)[0]))
a=co.fetchall()
a=numpy.array(a).tolist()
#print a
print len(a)
sql="insert into `%s`"%str.lower(list(i)[0])+"(open,high,low,close,volume,amt,date_time) values(%s,%s,%s,%s,%s,%s,%s)"
print sql
cur.executemany(sql,a)
conn.commit()
'''
n+=1
except:
print 'fail'
print n,'n'
#conn1.commit()
#co.close()
cur.close()
"""
import MySQLdb
conn=MySQLdb.connect(host='localhost',user='root237',passwd='root237',db='hushen300',port=3306)
cur=conn.cursor()