The multidimensional arrays numpy python

 

 

NumPy (Numerical Python) is an extension library Python language,

Support a large number of dimensions of the array and matrix operations, in addition, it provides a lot of math library for array operations.

Today for multidimensional arrays start to write blog

numpy part of the following functions:

1.ndarray, it is a multi-dimensional array having a vector arithmetic operation, space-saving.

2. The mathematical function may be used to distinguish the quasi-complete set of data for fast operation.

3. The tool can be used to read and write data on the disk, and operating system for memory mapping.

 

 

 

NumPy itself does not actually provide a very high level of data analysis functions, one particularly important reason to calculate the value of NumPy,

Because it can efficiently handle large data arrays.

This is because:

1.NumPy is in a contiguous block of memory storing data, independent of other built-in objects Python.

2.NumPy can perform complex calculations on the entire array, without the need for loop Python.

NumPy of ndarray: one kind multi-dimensional array object

An array in math

 

You can see the actual data value is not changed, the resulting output is only temporary results only.

ndarray is a general multi-dimensional data structure with the container, that is to say, all of the elements must be of the same type.

Each array has a Shape (shape) and a DTYPE (data type).

View ndarray the shape and dtype:

 

Creating ndarray

The easiest way to create an array is to use the array function.

It accepts all object type sequence (including other arrays), and then generates a new array containing NumPy incoming data.

In addition to np.array, there are some new functions can also be an array.

For example, zero and ones are all zeros or all can create an array of a specified length or shape.

empty can be used to create an array does not have any specific means.

Use these methods to create a multidimensional array, only you need to pass a tuple to represent the shape of:

  

arange is a Python built-in function range of the array version:

Here are some array creation function.

Because of concern is the numerical NumPy

Thus, if not specified, the data type basically float64 (floating point).

 

Transformation of an array by astype dtype

If the floating point number to an integer, the fractional part will be cut off.

If a full numeric character string arrays, can also be used astype convert it to a numeric value.

Call astype always create a new array (a data backup), even when the same new and old dtype dtype.

 

Guess you like

Origin www.cnblogs.com/oldfish123/p/12446065.html