转置
it = [[1,2,3],[4,5,6]]
i = np.array(it)
print(i.T)
ones()函数根据指定的形状和数据类型生成全为1的数组
numpy.ones(shape,dtype=None)
shape数组的形状
zeros()函数根据指定的形状和数据类型生成全为0的数组
numpy.zeros(shape,dtype=None)
full()函数根据指定的形状和数据类型生成数组,并用指定数据填充
numpy.full(shape,fill_value,dtype=None)
identity()函数创建单位矩阵
numpy.identity(n,dtype=None)
import numpy as np
a = np.ones([2,3],dtype=np.int32)
print(a)
b = np.zeros([3,4])
print(b)
c = np.full([2,3],10.)
print(c)
d = np.identity(6)
print(d)
[[1 1 1]
[1 1 1]]
[[0. 0. 0. 0.]
[0. 0. 0. 0.]
[0. 0. 0. 0.]]
[[10. 10. 10.]
[10. 10. 10.]]
[[1. 0. 0. 0. 0. 0.]
[0. 1. 0. 0. 0. 0.]
[0. 0. 1. 0. 0. 0.]
[0. 0. 0. 1. 0. 0.]
[0. 0. 0. 0. 1. 0.]
[0. 0. 0. 0. 0. 1.]]