#_*_ coding:utf-8 _*_ImportNumPy as NP#Create an arrayA=np.array ([[1.,7.,0.],[-2.,1.,2.]])Printa#Main properties of Ndarray:#number of Ndarry.ndim array rowsPrintA.ndim#Naarray.shape: Number of array dimensionsPrintA.shape#ndarry.size: Total number of array elementsPrinta.size#Ndarray.dtype: Type of array elementPrintA.dtype#ndarray.itemsize: The size of each element in the array that occupies bytesPrinta.itemsize#ndarray.date: Data buffers for array elementsPrintA.data#Special Arrays##1 Zeros ArrayZero=np.zeros (3,4)##2 ones ArrayOne=np.ones (bis)##empty数组Empty=np.empty (5,5)#Sequence Array##arange函数: Start value, end value, step sizeArange=np.arange (10,30,5)##linspace函数: Number of Start value termination value elements#Array Operations## arrays can be subtraction exponentiation and so on#Array Copy#deep copy through the. Copy () method#Matrix#the difference between matrix and array is that the matrix follows the mathematical operation Law##两种创建矩阵的方式A=np.matrix ('1.0 2.0; 3.0 4.0') B=np.matrix ([1.0,2.0],[3.0,4.0])##转置A.T##矩阵乘法A *B##矩阵的逆A.i
Python--numpy Simple Practical example