ndarray 数组储存单一数据类型多维数组
属性
- ndim 返回int 表示数组维数
- shape 返回tuple 尺寸 (m,n)
- size int 元素总数,等于数组形状乘积(m*n)
- dtype data-type 数组中元素类型
- itemsize int 数组每个元素的大小
数组
reshape 改变数组
numpy.arange(start, stop, step, dtype) step 步长
1.等差/等比
np.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None)
num = 要生成的等步长的样本数量,默认为50
endppoint = 该值为 true 时,数列中中包含stop值,反之不包含,默认是True。
retstep = 如果为 True 时,生成的数组中会显示间距,反之不显示。
np.logspace(start, stop, num=50, endpoint=True, base=10.0, dtype=None) base =对数 log 的底数。
2.zeros等基本数组
np.zeros((m,n)) 00数组 ones((m,n)) 11数组
np.eye(x) 单位矩阵 diag([x,y,z....]) 对角矩阵
3.数组乘法
np.array(a) * np.array(b