Numpy ndarray类有五个基本属性
属性名 | 描述 |
---|---|
shape | tuple类型,包含每个维度的元素个数 |
size | array中的元素个数总和 |
ndim | 维数 |
nbytes | 存储数据占用的字节数 |
dtype | 元素的数据类型 |
![](https://img.haomeiwen.com/i10758717/03036e836d33f615.png)
五个基本属性中,最难理解的就是Axis。在Numpy中,dimensions are called axes. The number of axes is rank
![](https://img.haomeiwen.com/i10758717/88bc365a831c12eb.png)
从程序员的视角
- axis = 0,意味着按axis0的方向,取数据执行运算
-
axis = 1,意味着按axis1的方向,取数据执行运算
按axis方向取数据进行运算
按轴方向计算
array的连接concatenate
- axis = 0,意味着按axis0的方向连接,axis0的数值增大
-
axis = 1,意味着按axis1的方向连接,axis0的数值增大
按轴连接
网友评论