Numpy学习笔记(一)
Import numpy as np
import numpy as np
if __name__ == '__main__':
# 构建一个数组
tian=[1,2,3,4,5,6,7,8,9,0]
print(type(tian))
newTian=np.array(tian)
print(newTian)
print(type(newTian))
tian=[[1,2,3,4,5,6,7,8,9,0],[1,2,3,4,5,6,7,8,9,0]]
twoTian=np.array(tian)
print(twoTian)
tian=np.arange(1,10,2)
print(tian)
tian=np.linspace(1,10,5)
print(tian)
#5行4列
shepe=(5,4)
tian=np.zeros(shepe)
print(tian)
tian=np.ones(shepe)
print(tian)
tian=np.random.random(shepe)
print(tian)
tian=np.random.random(shepe)
tian.fill(99)
print(tian)
#五行五列的对角线矩阵
tian=np.eye(5)
print(tian)
zhang=[["1","2","3","5"],["1","2","3","5"]]
newZhang=np.array(zhang)
print(newZhang.dtype)
newZhang=newZhang.astype(np.float32)
print(newZhang)
tian=np.identity(5)
print(tian)
#输出维度
print(tian.ndim)
#输出形状
print(tian.shape)
#其中的元素数量
print(tian.size)
周六愉快~
评论