当前位置: 首页 > news >正文

关于网站开发的开题报告服务器 免费

关于网站开发的开题报告,服务器 免费,微信里的小程序怎么制作方法,手机端做网站软件NumPy数值计算基础实验数据#xff1a; 链接#xff1a;https://pan.baidu.com/s/1-E2ShVTdI0X5lwDtMLFFsQ 提取码#xff1a;0929 代码实现#xff1a; 之前不会的地方#xff1a; 1#xff0e;读取文件 使用numpy内置的loadtxt()函数以及这个函数的参数frame#x… NumPy数值计算基础实验数据 链接https://pan.baidu.com/s/1-E2ShVTdI0X5lwDtMLFFsQ 提取码0929 代码实现 之前不会的地方 1读取文件 使用numpy内置的loadtxt()函数以及这个函数的参数frame要读取的文件dtype读取后的数据类型delimiter读取文件中的数据分隔符 #参数列表fname要读取的文件dtype读取后的数据类型delimiter读取文件中数据的分隔符self.datanp.loadtxt(fnamepath,dtypestr,delimiter,) 2数据的切分索引 self.dataself.data[1:,:]#去掉第一行标签行 self.colindexself.data[0,:]#得到标签行3将数据中的年份季度带小数的浮点数转化为不带浮点数的整数使用了numpy中的np.char.replace()函数 #需要将数据中的年份和季度中的小数部分去掉 self.data[:,:2]np.char.replace(self.data[:,:2],.0,) #data[:,:2]是数据中的前两列4.查找满足条件的行索引 index np.where((self.data[:, 0] year) (self.data[:, 1] quarter)) # 使用where方法返回符合给定年份和季度的行索引5.实现变量的展平 import numpy as npfp./macrodata.csv#要读取的文件 op./test.csv#输出文件class processdata:colmap {year: 0, quarter: 1, gdp: 2, realcons: 3, realinv: 4, realgovt: 5, realdpi: 6, cpi: 7, \m1: 8, tbilrate: 9, unemp: 10, pop: 11, infl: 12, realint: 13} # 定义一个字典用来转换字符串列名与列索引def __init__(self,path):#定义构造函数#参数列表fname要读取的文件dtype读取后的数据类型delimiter读取文件中数据的分隔符self.datanp.loadtxt(fnamepath,dtypestr,delimiter,)self.dataself.data[1:,:]#去掉第一行标签行self.colindexself.data[0,:]#得到标签行#需要将数据中的年份和季度中的小数部分去掉self.data[:,:2]np.char.replace(self.data[:,:2],.0,)#data[:,:2]是数据中的前两列def lookupdata(self,year,quarter,col):#查看任意时间点的GDP或者人口信息 col传入gdp或popyear str(int(year))quarter str(int(quarter))index np.where((self.data[:, 0] year) (self.data[:, 1] quarter)) # 使用where方法返回符合给定年份和季度的行索引index np.array(index)result The col in quarter str(quarter) , year str(year) is if index.size 0: # 若没有查找到符合条件的行tmp np.where(self.data[:, 0] year)tmp np.array(tmp)if tmp.size 0: # 若没有找到该年份的行error The given year str(year) is out of range...else: # 找到年份但没找到对应的季度error The given quarter str(quarter) is not found for the given year str(year) ...print(error)return errorelse: # 找到了符合条件的结果print(result str(self.data[index[0][0]][processdata.colmap[col]]) ...)return self.data[index[0][0]][processdata.colmap[col]]def calPerCapitaGDP(self, year, quarter): # 计算人均GDPyear str(int(year))quarter str(int(quarter))index np.where((self.data[:, 0] year) (self.data[:, 1] quarter)) # 使用where方法返回符合给定年份和季度的行索引index np.array(index)result The Per Capita GDP in quarter str(quarter) , year str(year) is if index.size 0: # 若没有查找到符合条件的行tmp np.where(self.data[:, 0] year)tmp np.array(tmp)if tmp.size 0: # 若没有找到该年份的行error The given year str(year) is out of range...else: # 找到年份但没找到对应的季度error The given quarter str(quarter) is not found for the given year str(year) ...print(error)return errorprint(result str(float(self.data[index[0][0]][2]) / float(self.data[index[0][0]][11])) ...) # 第二列数据/第11列数据return float(self.data[index[0][0]][2]) / float(self.data[index[0][0]][11])def flattendata(self, col[gdp, pop]): # 展平方法collist [processdata.colmap[i] for i in col] # 将要展平的列的列名转换成对应的数值索引data self.data[:, collist] # 提取这些列的数据colarr np.zeros((self.data.shape[0], 1), dtypenp.float)indexdata self.data[:, [0, 1]] # 提取年份和季度信息indexdata indexdata.repeat(len(col), axis0) # 对年份和季度两列进行纵向重复重复的次数为要展平的列数repeat是对所有行整个进行重复newdata data.flatten().reshape(-1, 1) # 使用flatten方法将要展平的列展平并转为列向量newcol collist * self.data.shape[0] # 将要展平的列的列号整个进行横向重复与repeat重复方式对应重复次数为原始数据的行数newcol np.array(newcol).reshape(-1, 1)tmp np.hstack((indexdata, newdata)) # 将重复后的日期季度列与展平后的列向量进行横向合并tmp np.hstack((tmp, newcol)) # 再与其原数据所在列号生成的列进行横向合并newcolindex np.array([year, quarter, values, columns number])tmp np.vstack((newcolindex, tmp)) # 添加新的列名return tmpdef printdata(self):data1 np.vstack((self.data[:, 2].reshape(-1, 1), self.data[:, 11].reshape(-1, 1)))print(data1.shape)prdataprocessdata(fp)#定义了一个类对象来实现这些方法 print((a):) prdata.lookupdata(2000,1,gdp) print((b):) prdata.lookupdata(2000,1,pop) print((c):) prdata.lookupdata(2020,1,gdp) print((d):) prdata.lookupdata(2000,6,pop) print((e):) prdata.calPerCapitaGDP(2000,1) print((f):) flatdataprdata.flattendata()np.savetxt(op,flatdata,delimiter,,fmt%s)#保存展平后的结果print(End!) input(按回车键结束)
http://www.pierceye.com/news/435870/

相关文章:

  • 品牌设计公司品牌设计公司排名百家号优化上首页
  • 广州网站车管所深圳东门大厦
  • 门户网站 建设商 排名网站下载的视频怎么变成本地视频
  • 国外品牌设计网站中华始祖堂室内设计
  • 建设网站服务无极最新招聘
  • 广东省建设教育协会是什么网站揭东建设局网站
  • 那家专门做特卖的网站godaddy 搭建网站
  • 网络舆情处置的五个步骤新人学会seo
  • 网站开发要做什么在线网页转pdf
  • 购物网站开发教程中文如何调整wordpress页面的顺序
  • 网站网页设计制作教程成都外贸seo
  • 网站开发的资料设备英国搜索引擎
  • 什么样企业需要网站建设网络规划毕业设计
  • 广东制作公司网站和谐校园网站建设
  • 找潍坊做网站的h5用什么软件做的
  • 南宁网站推广费用0505网页制作与网站建设
  • 2345电视剧网站免费电子营业执照
  • 河北省沧州建设厅网站怎样保存网站资料 做证据
  • 网站同时做竞价和优化可以吗做网站游戏推广赚钱吗
  • 台州建站模板搭建上海远程教育网站设计与开发公司
  • 网站如何做淘客类似58同城分类信息网站开发
  • 网站源码文件安装教程苏州网站建设致宇
  • 免费注册域名网站知乎做网站做图电脑需要什么配置
  • 高埗做网站营销策略分析包括哪些内容
  • wordpress获取站点链接网站门户
  • flashxml网站模板网站后期培训机构全国排名
  • 企业网站设计网站页面设计中为什么要有优先级排列
  • 暗网是什么网站滨江区网站开发公司
  • 南京网站排名优化费用株洲58同城网站建设电话
  • 电子商务网站建设与管理理解上海网站推广企业