# encoding=utf-8 import numpy as np l = [[1, 2, 3], [1, 3, 5]] type(l) # list # np.arraynpl = np.array(l, dtype=np.int16) # np.array,type(npl) # np.arraynpl.shape # npl.ndim # 缁村害 npl.dtype # npl.size # # np.zeros([3, 4]) # 0np.ones([3, 4]) # 1 # np.random.rand(2, 4) # 2 X 4 np.random.rand() # np.random.randint(1, 5, 5) # 51~5 np.random.randn(1, 5) # np.random.choice([10, 20, 30]) # np.random.beta(10, 20, 100) # BETA1~10100 # npl = np.arange(1, 11).reshape([2, 5]) # 25np.exp(npl) # e,nplnp.exp2(npl) # 2,nplnp.sqrt(npl) # np.sin(npl) # sin np.log(npl) # log # list = np.array([[[1, 2, 3], [4, 5, 6, ]], [[7, 8, 9], [10, 11, 12]], [[13, 14, 15]]]) list.sum() # list.sum(axis=0) # axix list.max(axis=0) # # list1 = np.array([1, 2, 3, 4]) list2 = np.array([2, 3, 4, 5]) list1 + list2 # list1+―*/list1 list1 ** 2 # np.dot(list1.reshape([2, 2]), list2.reshape([2, 2])) # dot np.concatenate((list1, list2)) # hstacknp.vstack((list1, list2)) # np.split(list1, 2) #
文章来源: R语言基础