last update date: 2020-04-01 modify nums : 1 last read date: 2020-04-01
关键词 5星 numpy 代码
摘要
通过造出的5种不同维度的数据,学习numpy多维数组(对多维空间的一种实现)基本概念、切片切块、其他常用函数
目的
掌握核心的numpy操作技能
环境
- python3
- Anaconda3
说明
0 资料摘录
1 数据准备
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
# 0维 arr0 = np.array ( 0.05126289 ) # 1维 arr1 = np.array ( [ 0.05126289, 0.66402449, 0.22970131, 0.73774777] ) # 2维 arr2 = np.array ( [ [ 0.05126289, 0.66402449, 0.22970131, 0.73774777], [ 0.72501932, 0.20642975, 0.38318838, 0.70826703], [ 0.86349343, 0.34179916, 0.32829582, 0.55624637] ] ) # 3维 arr3= np.array( [ [ [ 0.05126289, 0.66402449, 0.22970131, 0.73774777], [ 0.72501932, 0.20642975, 0.38318838, 0.70826703], [ 0.86349343, 0.34179916, 0.32829582, 0.55624637] ], [[ 0.59645461, 0.83145358, 0.85956141, 0.81924494], [ 0.01116166, 0.71089623, 0.91432385, 0.66226528], [ 0.5791923 , 0.42764113, 0.56575513, 0.54864404] ] ] ) # 4维 arr4= np.array( [ [ [ [ 0.05126289, 0.66402449, 0.22970131, 0.73774777], [ 0.72501932, 0.20642975, 0.38318838, 0.70826703], [ 0.86349343, 0.34179916, 0.32829582, 0.55624637] ], [[ 0.59645461, 0.83145358, 0.85956141, 0.81924494], [ 0.01116166, 0.71089623, 0.91432385, 0.66226528], [ 0.5791923 , 0.42764113, 0.56575513, 0.54864404] ] ], [ [ [ 1.05126289, 1.66402449, 1.22970131, 1.73774777], [ 1.72501932, 1.20642975, 1.38318838, 1.70826703], [ 1.86349343, 1.34179916, 1.32829582, 1.55624637] ], [[ 1.59645461, 1.83145358, 1.85956141, 1.81924494], [ 1.01116166, 1.71089623, 1.91432385, 1.66226528], [ 1.5791923 , 1.42764113, 1.56575513, 1.54864404] ] ] ] ) # 5维 arr5= np.array( [ [ [ [ [ 0.05126289, 0.66402449, 0.22970131, 0.73774777], [ 0.72501932, 0.20642975, 0.38318838, 0.70826703], [ 0.86349343, 0.34179916, 0.32829582, 0.55624637] ], [[ 0.59645461, 0.83145358, 0.85956141, 0.81924494], [ 0.01116166, 0.71089623, 0.91432385, 0.66226528], [ 0.5791923 , 0.42764113, 0.56575513, 0.54864404] ] ], [ [ [ 1.05126289, 1.66402449, 1.22970131, 1.73774777], [ 1.72501932, 1.20642975, 1.38318838, 1.70826703], [ 1.86349343, 1.34179916, 1.32829582, 1.55624637] ], [[ 1.59645461, 1.83145358, 1.85956141, 1.81924494], [ 1.01116166, 1.71089623, 1.91432385, 1.66226528], [ 1.5791923 , 1.42764113, 1.56575513, 1.54864404] ] ] ], [ [ [ [ 5.05126289, 5.66402449, 5.22970131, 5.73774777], [ 5.72501932, 5.20642975, 5.38318838, 5.70826703], [ 5.86349343, 5.34179916, 5.32829582, 5.55624637] ], [[ 5.59645461, 5.83145358, 5.85956141, 5.81924494], [ 5.01116166, 5.71089623, 5.91432385, 5.66226528], [ 5.5791923 , 5.42764113, 5.56575513, 5.54864404] ] ], [ [ [ 6.05126289, 6.66402449, 6.22970131, 6.73774777], [ 6.72501932, 6.20642975, 6.38318838, 6.70826703], [ 6.86349343, 6.34179916, 6.32829582, 6.55624637] ], [[ 6.59645461, 6.83145358, 6.85956141, 6.81924494], [ 6.01116166, 6.71089623, 6.91432385, 6.66226528], [ 6.5791923 , 6.42764113, 6.56575513, 6.54864404] ] ] ] ] )
2 基本概念
2.1 维数
2.2 数组形状
2.3 数组大小
2.3 切片
总结
通过 : 和 , 两个符号 和数字的组合搭配,就可以获得不同的数据选择效果
- (3,4)的二维数组
图 numpy二维切片
- (2,3,4)的三维数组
图 numpy三维数组切片
3 常用函数
3.1 数组生成
参考资料
【本地】20200401_numpy_learn.ipynb
【本地】20200401_numpy_learn.txt
【本地】20180804_numpy..txt
【本地】20180804_numpy_v2..txt
【本地】b0100 umpy 切片.xlsx
【博文】[b0044] numpy_快速上手 (2018-09-19 17:22)
【网页】Numpy包函数的使用(史上最全) (@WSX_WOLF 2018-05-19 )
备注
Todo
- 矩阵计算
- 数学函数
修改记录
- 2020-04-01 创建