摘要: import numpy as np #行合并 a = np.arange(6).reshape(2,3) b = np.random.randint(10,20,size=(4,3)) print(a) print(b) print('******************************* 阅读全文
posted @ 2023-01-20 17:52 不迷路的小孩 阅读(19) 评论(0) 推荐(0) 编辑
摘要: import numpy as np arr = np.arange(5) print(arr) print(arr.shape) #method1 print(arr[np.newaxis,:]) print(arr[np.newaxis,:].shape) print(arr[:,np.newa 阅读全文
posted @ 2023-01-20 17:52 不迷路的小孩 阅读(44) 评论(0) 推荐(0) 编辑
摘要: import numpy as np arr = np.arange(12).reshape(3,4) print(arr) print(np.sum(arr)) print(np.prod(arr)) print(np.cumsum(arr)) print(np.cumprod(arr)) pri 阅读全文
posted @ 2023-01-20 17:51 不迷路的小孩 阅读(20) 评论(0) 推荐(0) 编辑
摘要: import numpy as np np.random.seed(666) print(np.random.rand(5)) print(np.random.rand(3,4)) print(np.random.rand(2,3,4)) print('*********************** 阅读全文
posted @ 2023-01-20 17:51 不迷路的小孩 阅读(39) 评论(0) 推荐(0) 编辑
摘要: import numpy as np #基础索引 x1 = np.arange(10) x2 = np.arange(20).reshape(4,5) print(x1) print(' ') print(x1[0],x1[9],x1[-1]) print(' ') print(x1[2:4]) p 阅读全文
posted @ 2023-01-20 17:51 不迷路的小孩 阅读(20) 评论(0) 推荐(0) 编辑
摘要: import numpy as np x1 = np.array([1,2,3,4,5,6,7,8]) x2 = np.array( [ [1,2,3,4], [5,6,7,8] ]) #返回元组,表维度 print(x1.shape) print(x2.shape) #返回数字,表维度 print 阅读全文
posted @ 2023-01-20 17:50 不迷路的小孩 阅读(33) 评论(0) 推荐(0) 编辑
摘要: import numpy as np from timeit import timeit def python_sum(n): a=[i**2 for i in range(n)] b=[i**3 for i in range(n)] c=[] for i in range(n): c.append 阅读全文
posted @ 2023-01-20 17:50 不迷路的小孩 阅读(14) 评论(0) 推荐(0) 编辑