Python Small white Learning road __python

Source: Internet
Author: User
Tags square root
Python Learning (i)
Having just studied this year, and the tutor's research direction is data mining, although before the professional is a computer, but the university four years of basic in beer and skittles spent, so basic calculation programming small white one, learning Python is a serious re-learning a language, so want to write a blog every week to promote their own learning, There are many deficiencies in the learning process, I hope you will correct me.
Getting started with Python 1.numpy
    NumPy is a basic library that Python uses for scientific computing, especially for data analysis, is the foundation of a large number of Python math and scientific computing packages (such as pandas). Ndarray is the heart of the NumPy library, the dimensions of the array and the number of elements are determined by the array's shape (shape), and the dimensions of the array are known as axes (axes), and the number of axes is
   To create an n-dimensional array (ndarray),
    use the array () function
    argument as a single-layer or nested list: b = Np.array ([1.3,2.2],[0.3,4.1])
    parameter is a nested meta-ancestor or a tuple list: b = Np.array ( 1.3,2.2)
    parameter is a list consisting of Ganso or lists: b = Np.array ((1.3,2.2), [4.5,6.6], (0.3,4.1))
2. The method of creating the array from the band
    2.1 Zeros (): Generates a dimension information specified by the shape parameter, an array
            Np.zeros ((3,3))
    2.2 ones (): Ibid., the generated elements are all 1, and the two functions are the default float
            np.ones (( 3,3)
    2.3 arange () function: Generates an array that contains a sequence of values by a specific rule, with a value of 0 starting with the default
    arange: Array ([0,1,.., 9])
    Arange (4,10): Array ( [4,5,6,7,8,9])
    Arange (0,12,3): Array ([0,3,6,9])
    arange (0,6,0.6): Array ([0.,0.6,1.2.....,5.4])
    Arange is not the same as Python range (). The range () function can only be used as an integer step

The above generation is a one-dimensional array, if you want to build a multidimensional array, you can add the reshape () function after Arange, specify the shape, the one-dimensional array split into different parts:

Np.arange (0,12). Reshape (3,4)
Array ([[0, 1, 2, 3],
[4, 5, 6, 7],
[8, 9, 10, 11]]

    2.4 random () function to generate n-dimensional random arrays
3. Basic Operation
    3.1 Arithmetic operator (+,-,*,/)--element level, used only for
    3.2 matrix (inner) product between elements with the same location:  Np.dot (a,b) or A.dot (B)
    3.3 Common functions (each element in the array): such as sqrt ( ): Calculates the square root; log (), sin ()
    ... 3.4 Aggregate function: Operates on a set of values (such as an array), returning a single value as the result, such as SUM (), Min (), Max (), mean (), STD () ....

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.