Python Library Introduction------Numpy

Source: Internet
Author: User

NumPy Introduction:The numpy system is an open-source numerical extension of Python. This tool can be used to store and manipulate large matrices, which is much more efficient than Python's own nested list (nested list structure) structure, which is also useful for representing matrices (matrix).

NumPy (Numeric Python) offers a number of advanced numerical programming tools such as matrix data types, vector processing, and sophisticated operations libraries. Designed for rigorous digital processing. Many of the major financial companies used, as well as the core scientific computing organizations such as: Lawrence Livermore,nasa use it to deal with some of the original use of C++,fortran or MATLAB and other tasks.

NumPy provides high performance, multidimensional array objects, and work tools that use these arrays. Its array can be used as an efficient general-purpose multidimensional container data. You can define any type of data. 1. First look at the data type of NumPy (1)Signed integer typeint8:1-byte int16:2-byte int32:4-byte int64:8-byte

(2) unsigned integer type

Uint8:1-byte Uint16:2-byte Uint32:4-byte Uint64:8-byte

(3) C-language integer type

Int_ INTC intp Short Long Longlong

(4) floating-point floating boolean plural type complex string type str datetime type data and time raw data block

(5) Character codes for built-in data types

  • ? : Boolean, for example:
  • b:signed byte i4:32-bit signed integer
  • b:unsigned byte u2:16-bit signed integer
  • i:signed integer ========= "F8:64-bit floating-point
  • u:unsigned integer U25:25-character string
  • F:floating-point v10:10-byte Wide Data
  • C:complex
  • M:timedelta
  • M:datetime
  • O:python Object
  • S: (Byte) string
  • U:unicode string
  • V:raw data (void)

Next we will illustrate the various uses of the NumPy array:

(1) Ndarray-----Multidimensional Degree Group

Explanation: n--number d--dimension dimensional array--array


Let's take a look at the basic examples:

Ndarray has the properties:

Dtype shape Ndim Size itemsize nbytes flags base

The following describes the properties using:

(2)axis

defines an axis for an array with more than one dimension. The two-dimensional array has two axes: the first is run vertically down through the line (axis 0) and the second across the column (axis 1) horizontally .

For example: [[[0 1 2]

[3 4 5]]

[[6 7 8]

[9 10 11]] ]

SUM (axis=0): [[6 8 10] [12 14 16]]

SUM (Axis=1): [[3 5 7] [15 17 19]]

SUM (axis=3): [[3 12] [21 30]]

(3) Create a multidimensional degree group

① through Np.array------This is what it says, it's simple.

② through functions

Function methods are: empty zeros ones Asarray fromiter arange full eye random.random Linspace

Implementations are similar:

(4) Reshaping of multidimensional arrays:

(5) Indexes and slices

Integer array index can construct arbitrary array

Using data from another array

Python Library Introduction------Numpy

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.