Python--numpy Simple Practical example

Source: Internet
Author: User

#_*_ 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.