码迷,mamicode.com
首页 > 其他好文 > 详细

111

时间:2018-07-07 15:54:23      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:odi   开始   value   The   anti   utf-8   tick   port   index   

# -*- coding: utf-8 -*- #auther tonyxiao import xlrd workbook = xlrd.open_workbook(‘D:/Desktop/workload.xls‘) # 打开excel数据表 SheetList = workbook.sheet_names() # 读取电子表到列表 SheetName = SheetList[0] # 读取第一个电子表的名称 Sheet1 = workbook.sheet_by_index(0) # 电子表索引从0开始 Sheet1 = workbook.sheet_by_name(SheetName) # 实例化电子表对象 a = 0 b = 0 c = 0 d = 0 e = 0 f = 0 g = 0 for i in range(Sheet1.nrows): rows = Sheet1.row_values(i) if rows[5] == ‘suzu - Suo Zhu‘: a += 1 if rows[5] == ‘fxia - Feng Xiao‘: b += 1 if rows[5] == ‘wyql - David Liu‘: c += 1 if rows[5] == ‘jnug - Jingyuan Gu‘: d += 1 if rows[5] == ‘ruim - Ruiming Ma‘: e += 1 if rows[5] == ‘ckul - Kun Li‘: f += 1 print(‘suzu - Suo Zhu‘, a) print(‘fxia - Feng Xiao‘, b) print(‘wyql - David Liu‘, c) print(‘jnug - Jingyuan Gu‘, d) print(‘ruim - Ruiming Ma‘, e) print(‘ckul - Kun Li‘, f) #画图 import numpy as np import matplotlib.mlab as mlab import matplotlib.pyplot as plt X=[1,2,3,4,5,6] Y=[a,b,c,d,e,f] fig = plt.figure() plt.bar(X,Y,0.4,color="green") plt.xlabel("name") plt.ylabel("ticket quantity") plt.title("workload chart") plt.show() plt.savefig("barChart.jpg")

111

标签:odi   开始   value   The   anti   utf-8   tick   port   index   

原文地址:https://www.cnblogs.com/latefall/p/9277113.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!