forked from Rockyzsu/stock
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvisual.py
32 lines (30 loc) · 916 Bytes
/
visual.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
# -*-coding=utf-8-*-
__author__ = 'Rocky'
'''
http://30daydo.com
Contact: [email protected]
'''
import pandas as pd
import matplotlib.pyplot as plt
import os
#图形显示某一天的涨跌幅分布
def count_up_down(filename):
total=[]
df=pd.read_excel(filename)
count= len(df[(df['changepercent']>=-10.2) & (df['changepercent']<-9)])
total.append(count)
for i in range(-9,9,1):
count= len(df[(df['changepercent']>=i*1.00) & (df['changepercent']<((i+1))*1.00)])
total.append(count)
count= len(df[(df['changepercent']>=9)])
total.append(count)
print(total)
df_figure=pd.Series(total,index=[range(-10,10)])
print(df_figure)
fg=df_figure.plot(kind='bar',table=True)
plt.show(fg)
if __name__=='__main__':
foler=os.path.join(os.getcwd(),'data')
filename='2017-04-13_all_.xls'
full_path=os.path.join(foler,filename)
count_up_down(full_path)