numpy.arange(start,end,step)
创建一个numpy 对象
如
numpy.arange(1,7) #[1 2 3 4 5 6]
跟序列的有点相似,range方法吧
numpy对象的dtype 属性是一个描述对象本身的一个类型
a =- numpy.arange(1,7)
b = a.astype(numpy.str_)
print(a,b,sep="\n")
#[1 2 3 4 5 6]
#['1' '2' '3' '4' '5' '6']
a.astype 并不会改变a对这个地址的描述,改变的只是b对这个地址的描述
numpy.dtype 打印出元素类型
print(a.dtype) #int32
a.shape #(6,) shape 表示数组的维度
a.reshape((2,3)) #改变数组的维度 二行三列 [[1 2 3]
[4 5 6]]
ravel 将numpy对象变成一维
a = np.arange(1,7)
a.reshape(2,3)
print(a)
print(a.ravel())
[[1 2 3]
[4 5 6]]
[1 2 3 4 5 6]
[1 2 3 4 5 6]
复制变维 flatten
复制,类似于 深拷贝
就地变维
nmpy.shape = ()
组合
垂直组合
v = numpy.vstack((u,d))