Wu Yuxiong - natural born Numpy library study notes: NumPy Ndarray objects

The most important feature is the N-dimensional array NumPy objects ndarray, which is a collection of different types of data, labeled 0 to index the start elements in a set. 
ndarray object is a multidimensional array used to store the same type of element. 
ndarray Each element has the same size storage area in memory. 
Internal ndarray consists of the following: 
a pointer to data (data memory or a memory-mapped file) pointer. 
Data type or dtype, describes a fixed grid size value in the array. 
An array of a shape (Shape) tuples, each tuple represents the size of the dimension. 
A span tuple (stride), wherein the integer refers to an element required to advance the current dimension " across " the number of bytes.

 

 

import numpy as np 
a = np.array([1,2,3])  
print (a)
# Than one dimension   
Import numpy NP AS 
A = np.array ([[. 1, 2], [. 3,. 4 ]])  
 Print (A)
# Smallest dimension   
Import numpy NP AS 
A = np.array ([. 1, 2, 3,4, 5], ndmin = 2 )  
 Print (A)
# dtype 参数  
import numpy as np 
a = np.array([1,  2,  3], dtype = complex)  
print (a)

Guess you like

Origin www.cnblogs.com/tszr/p/12228646.html