Python读取xlsx数据生成图标代码实例

作者:悄悄成长 时间:2022-01-11 11:35:56 

运行结果:

Python读取xlsx数据生成图标代码实例

程序代码如下:


#将excel中的数据进行读取分析
import openpyxl
import numpy as np
import math
import matplotlib.pyplot as pit
wk=openpyxl.load_workbook('信息11.xlsx')
sheet=wk.active
rows=sheet.max_row
cols=sheet.max_column
lst1=[]
lst2=[]
for i in range (1,rows+1):
 size1=sheet.cell(i,1).value
 lst1.append(size1)
 size2 = sheet.cell(i, 2).value
 lst2.append(size2)
num=0
dic_size={}
for item in lst1:
 dic_size[lst1[num]]=lst2[num]
 num+=1
#弄成百分比的形式
lst_total=[]
for item in dic_size:
 lst_total.append([item,dic_size[item]])
labels=[item[0] for item in lst_total] #使用列表生成式,得到饼图的标签
fraces=[item[1] for item in lst_total] #饼图中的数据源
pit.rcParams['font.family']=['SimHei'] #单独的表格乱码的处理方式
pit.scatter(labels,fraces)
pit.plot(labels,fraces,color='green')
pit.bar(labels,fraces,width=5,color='red')
z1=np.polyfit(labels,fraces,2)
p1=np.poly1d(z1)
x = np.linspace(0, 500, 50)
y=-0.00024*(x**2)+0.1013*(x)+10.23
pit.plot(x,y,color='purple')
#pit.savefig('图.jpg')
yre=[]
for item in labels:
 y=-0.00024*(item**2)+0.1013*(item)+10.23
 yre.append(round(y,6))
print(fraces)
print(yre)
result=[]
a=0
mse=0
mae=0
for i in range(0,10):
 a+=round(fraces[i]-yre[i],6)
 mae+=round(math.fabs(fraces[i]-yre[i]),6)
for i in range(0,10):
 result.append(round(fraces[i] - yre[i]-round(a/10,6), 6))
 mse += round((fraces[i] - yre[i]-round(a/10,6)) * (fraces[i] - yre[i]-round(a/10,6)), 6)
print(result)
print('均值',round(a/10,6))
print('均方误差',round(mse/10,6))
rmse=math.sqrt(round(mse/10,6))
print('均方根误差',round(rmse,6))
print('平均绝对误差',round(mae/10,6))
print('R平方的数值',1-((round(a/10,6))*round(a/10,6))/round(mse/10,6))
print(p1)
#pit.show()

来源:https://www.cnblogs.com/dazhi151/p/13424419.html

标签:Python,xlsx,图标
0
投稿

猜你喜欢

  • oracle 日期函数

    2010-07-23 13:32:00
  • IE6局部调用PNG32合并图片

    2009-03-11 21:24:00
  • Mootools 1.2教程(9)——输入过滤第二部分(字符串)

    2008-12-01 12:25:00
  • python 将列表中的字符串连接成一个长路径的方法

    2023-04-18 14:06:25
  • zen coding的dreamweaver插件安装教程

    2010-01-12 13:30:00
  • 捕捉并保存ASP运行错误的函数代码

    2012-11-30 20:24:43
  • asp实现在线人数统计代码

    2008-08-10 18:35:00
  • Codeigniter控制器controller继承问题实例分析

    2023-11-23 04:15:31
  • vertical-align表单元素垂直对齐

    2009-07-27 13:02:00
  • 详解tensorflow载入数据的三种方式

    2023-07-22 19:35:56
  • getWindow与isWindow

    2009-12-28 13:12:00
  • 交互因视觉设计而更完美

    2008-05-31 17:22:00
  • 在ASP中使用SQL语句之3:LIKE、NOT LIKE和 BETWEEN

    2007-08-11 12:30:00
  • HTML标签tbody的用法

    2009-11-02 10:11:00
  • 用户研究中的人物角色

    2010-02-08 12:15:00
  • javascript新闻图片轮换类

    2009-01-09 12:57:00
  • 如何在SQL Server中由原子建立分子查询

    2009-01-20 16:01:00
  • ACCESS数据库遇日文时内存溢出的最简单处理办法

    2009-07-09 14:04:00
  • 详解MySQL数据库中字符串的正确使用

    2010-06-20 15:01:00
  • python 读写、创建 文件的方法(必看)

    2023-08-07 11:37:40
  • asp之家 网络编程 m.aspxhome.com