Python Numpy basis Introduction

Numpy basis:

NumPy (Numerical Python) is an extension library Python language, supports a number of dimensions of the array and matrix operations, in addition, it provides a lot of math library for array operations.

Numeric NumPy's predecessor was first developed by Jim Hugunin with other collaborators, in 2005, Travis Oliphant Numeric combined with another in the nature of the characteristics of Numarray library, and joined the other expansion and development of NumPy. NumPy is open source and jointly safeguard the development of many collaborators.

First, create a simple array:

 

 Generating an array, comprises two arrays, with each of which has three randomly selected from the value in the standard normal distribution.

 

There are an array of the most common shape, dtpye property methods. Let's try to access it:

 

 Characterized the number of each dimension of the array: shape

dtype: common data type array is described float, int, etc.

 

 Here generation ndarray, and its array, Numpy arrays represent the same object: ndarray Object

 

 It can be found, and it does the same array, with the basic properties of the array.

 

zeros can create an array of one-time all-0

ones can create whole array of one-time 1

you can not create an array of empty array initialization

E.g:

 

 Note that, if you want to pass multi-dimensional arrays, you need to pass a tuple!

 

arange method np is the python built-in function range of the array version:

 

 

Astype methods may be used to explicitly convert the data type of the array:

 

 

 

NUmpy array arithmetic:

Batch data allows for operation without any loop.

I.e., element-wise manner to the quantization operation

 

 With the calculated scalar arithmetic operations, it will calculate the parameters passed to each element of the array.

 

Comparison between the array of the same size, will produce a Boolean value array.

 

Guess you like

Origin www.cnblogs.com/lesliechan/p/11780920.html