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

网站模版与模板的使用上海发布官方网

网站模版与模板的使用,上海发布官方网,深圳网站开发建设培训,2万元建设网站贵吗实验环境#xff1a;建立在Python3的基础之上 numpy提供了一种数据类型#xff0c;提供了数据分析的运算基础#xff0c;安装方式 pip install numpy导入numpy到python项目 import numpy as np本文以案例的方式展示numpy的基本语法#xff0c;没有介绍语法的细枝末节建立在Python3的基础之上 numpy提供了一种数据类型提供了数据分析的运算基础安装方式 pip install numpy导入numpy到python项目 import numpy as np本文以案例的方式展示numpy的基本语法没有介绍语法的细枝末节笔者认为通过查阅案例就能掌握基本用法。 numpy数组的基本概念 numpy默认所有元素具有相同的数据类型如果类型不一致会对其进行优化。如果元素类型不同将统一成一种类型优先级strfloatint import numpy as np t_list [1, 1.2, hello]print(t_list) t_list np.array([1, 1.2, hello])print(t_list) t_list np.array([1, 1.2])print(t_list)定义数组的时候可以声明数据类型 t_list np.array([1,2,3])print(t_list) t_list np.array([1,2,3], dtypenp.float32)print(t_list)numpy构造数组 1、np.ones(shape, dtype) shape(m,n) m行n列shape(m) m个元素的一维数组shape(m,) m个元素的一维数组shape(m,1) m行1列的二维数组 [[1],[2],[3]]shape(1,m) 1列m行的二维数组 [[1,2,3]]t_list np.ones(shape(5,4), dtypenp.int32)print(t_list)2、np.zeros(shape, dtype) t_list np.zeros(shape(5,3), dtypenp.int32)print(t_list)3、np.full(shape, fill_value, dtype) t_list np.full(shape(2,3,4), fill_value10, dtypenp.int32)print(t_list)4、np.eye(N,M,k,dtype) # 单位矩阵t_list np.eye(N5, dtypenp.float32)print(t_list) # 控制行列的矩阵t_list np.eye(N5, M4, dtypenp.int32)print(t_list) # 1向左偏移t_list np.eye(N5, k-1)print(t_list)5、np.linspace(start, stop, num, endpointTrue, retstepFalse, dtype) # 共11个数t_list np.linspace(0, 10, 10)print(t_list)# 共10个数t_list np.linspace(0, 10, 10, endpointFalse)print(t_list)6、np.arange(start, stop, step, dtype) t_list np.arange(1,10,2)print(t_list)7、np.random.randint(low, highNone, sizeNone, dtype) # 随机数t_list np.random.randint(1, 100, size(5,4))print(t_list)8、np.random.random(size) # 0到1之间的随机数t_list np.random.random(size(5,4))print(t_list)9、np.random.permutation() # 随机索引t_list np.random.permutation(10)print(t_list)10、属性 t_list np.full(shape(2,3,4), fill_value10, dtypenp.int32)print(t_list)# 维度print(t_list.ndim)# 形状print(t_list.shape)# 大小print(t_list.size)# 元素类型print(t_list.dtype)数组的索引和切片 1、索引 t_list np.array([1,2,3,4,5])# 以下标的方式访问print(t_list[0])# 以列表索引的方式访问print(t_list[[0,1,2,0,1,3]])# 以布尔类型访问得到数组中True的值但布尔列表的长度需要与数组长度相同print(t_list[[True,False,True,False,False]])# 数组可以做运算print(t_list 3)print(t_list[t_list 3])t_list np.array([[1,20,3],[2,30,4],[3,40,5]])print(t_list[0][1])# 下标可以放在一起print(t_list[0,1])# 高维数组t_list np.random.randint(1, 10, size(3,4,5), dtypenp.int32)print(t_list)print(t_list[1])print(t_list[1,1])print(t_list[1,1,1])2、切片 t_list np.random.randint(1,100,size(10), dtypenp.int32)print(t_list)# 切片print(t_list[2:5])t_list np.random.randint(1,100,size(5,6), dtypenp.int32)print(t_list)# 行切片print(t_list[1:3])# 列切片print(t_list[:,1:3])t_list np.random.randint(1,100,size(3,6,5), dtypenp.int32)print(t_list)print(t_list[:,:,1:3])3、变形 t_list np.random.randint(1,100,size(20), dtypenp.int32)# 一维数组变形为二维数组变形需要注意前后两个数组的元素个数相同print(t_list.reshape(4,5))4、连接 t_list np.random.randint(1,100,size(4,4))t_list2 np.random.randint(1,100,size(4,4))# 横向连接要求两个数组的横列大小相同t_list np.concatenate((t_list,t_list2), axis1)# 纵向连接要求两个数组的横列大小相同t_list np.concatenate((t_list,t_list2), axis0)t_list np.random.randint(1,100,size(4,4))t_list2 np.random.randint(1,100,size(4,4))np.hstack((t_list,t_list2))np.vstack((t_list,t_list2))5、切分 t_list np.random.randint(1,100,size(4,8))# 横向切分等份切分part1, part2 np.split(t_list, indices_or_sections2)print(part1)print(part2)# 纵向切分part1, part2 np.split(t_list, indices_or_sections2, axis1)print(part1)print(part2)t_list np.random.randint(1,100,size(5,7))part1, part2, part3 np.split(t_list, indices_or_sections[2,3])print(part1)print(part2)print(part3)part1, part2, part3 np.split(t_list, indices_or_sections[2,3],axis1)print(part1)print(part2)print(part3)part1, part2, part3 np.vsplit(t_list, indices_or_sections[2,3])print(part1)print(part2)print(part3)part1, part2, part3 np.hsplit(t_list, indices_or_sections[2,3])print(part1)print(part2)print(part3)6、复制 ct_list t_list.copy()ct_list[1,2] 1000print(t_list)print(ct_list)聚合操作 1、求和 t_list np.random.randint(1,100,size(4,8))# 求和print(t_list.sum())# 求均值print(t_list.mean())# 求最值print(t_list.max())print(t_list.min())# 最值索引print(t_list.argmax())print(t_list.argmin())# 标准方差print(t_list.std())# 方差print(t_list.var())# 中位数print(np.median(t_list))2、布尔运算 t_list np.array([True, False, True, True])# 只要存在一个True返回Trueprint(t_list.any())# 全部为Ture返回Trueprint(t_list.all())3、矩阵 t_list np.array([[1,2,3],[2,3,4]])t_list2 np.array([[1,2],[2,3],[3,4]])print(np.dot(t_list, t_list2))以上是numpy的基本操作numpy提供了操作数组的运算基础复杂业务处理还需要Pandas的加入。 ---------------------------END--------------------------- 题外话 感兴趣的小伙伴赠送全套Python学习资料包含面试题、简历资料等具体看下方。 CSDN大礼包全网最全《Python学习资料》免费赠送安全链接放心点击 一、Python所有方向的学习路线 Python所有方向的技术点做的整理形成各个领域的知识点汇总它的用处就在于你可以按照下面的知识点去找对应的学习资源保证自己学得较为全面。 二、Python必备开发工具 工具都帮大家整理好了安装就可直接上手 三、最新Python学习笔记 当我学到一定基础有自己的理解能力的时候会去阅读一些前辈整理的书籍或者手写的笔记资料这些笔记详细记载了他们对一些技术点的理解这些理解是比较独到可以学到不一样的思路。 四、Python视频合集 观看全面零基础学习视频看视频学习是最快捷也是最有效果的方式跟着视频中老师的思路从基础到深入还是很容易入门的。 五、实战案例 纸上得来终觉浅要学会跟着视频一起敲要动手实操才能将自己的所学运用到实际当中去这时候可以搞点实战案例来学习。 六、面试宝典 简历模板 CSDN大礼包全网最全《Python学习资料》免费赠送安全链接放心点击 若有侵权请联系删除
http://wiki.neutronadmin.com/news/207898/

相关文章:

  • 如何建立论坛网站甘肃企业建站系统费用
  • 大连鼎信网站建设公司地址网站运营工作具体做啥
  • 大连本站运营公司北京市工程建设交易中心
  • 建设银行网站安全性分析网站建设和微站建设的区别
  • 网站解析是什么意思免费加盟一件代发货源网站
  • 做苗木网站网站建站网站建设
  • 云南网站建设500前端用户中心 wordpress
  • 诸城哪有做公司网站和的数据库修改wordpress登录密码忘记
  • 网站建设新闻+常识网站建设栏目分级
  • 一个网站是怎么做出来的做网店去哪个网站货源好
  • 网站内容避免被采集网站做零售
  • 怎么自己做微网站吗如何写手机适配网站
  • 湖南建设工程竣工备案表查询网站企业网站设计与管理系统
  • 电商型网站网站建设合同 附件
  • 主机如何做网站空间常德seo公司
  • 高端旅游网站建设wordpress 快讯模板
  • 微信小程序外联网站网络平台推广方法
  • 动态背景网站优惠券网站做代理怎么样
  • 网站服务器 内容更新柳州企业网站建设
  • 免费领取永久云服务器深圳市seo网站设计多少钱
  • 墨刀做网站化州市住房和建设局网站
  • 最优的锦州网站建设焦作做网站的
  • 鹿班设计网站官网安徽安能建设集团网站
  • 免费购物网站程序wordpress条文件夹
  • 新民个人网站建设优势刷赞网站推广ks
  • 购物导购网站开发工程建筑公司
  • vue可以做pc的网站福建南平网站建设
  • 甘肃网站备案审核广州引流推广公司
  • 网站制作企wordpress 计划表格
  • 大公司网站色彩设计flash网站源码