Numpy
(unfinished) Numpy的ndarray、数学公式和矩阵使用、数据切片
NDarray and Matrix
lst = [[1,2,3],[4,5,6]] #2*3 array
a = np.array(lst) #create array from list
print(a.shape)
#(2,3) 因为这是一个2*3的矩阵
print(a.ndim)
#2 2 dimensions
print(a.dtype)
# numpy里的data type得是同一种类型,才能保证快速计算
print(a.size)
#6 总共有6个元素 b = np.arange(0, 10, 2, dtype='float') # create 1d array, [start, stop)
print(type(b)) # class 'numpy.ndarray'
print(b) #[0. 2. 4. 6. 8.]
print(b.shape) #(5,)
c = np.linspace(1.5, 2.5, 9) # create 1d array with float, [start, stop]
print(type(c)) # class 'numpy.ndarray'
print(c) #[1.5 1.625 1.75 1.875 2. 2.125 2.25 2.375 2.5 ]
print(c.shape) #(9,)
Last updated