numpy basic operations

class iinfo(object):
def init (self, int_type):
pass
def min(self):
pass
def max(self):
pass Does
this code define an object, self is a formal parameter, int represents integer data, and Define the maximum and minimum range?
a = np.array([0, 1, 2, 3, 4])
b = np.array((0, 1, 2, 3, 4))
The two output results are:
[0 1 2 3 4] <class'numpy.ndarray'>
[0 1 2 3 4] <class'numpy.ndarray'>
Why doesn't the parenthesis mean something else?
Create a two-dimensional array, three parentheses, create a three-dimensional array, four parentheses ,So on and so forth. . .
Both array() and asarray() can convert structure data into ndarray. The main difference between array() and asarray() is that when the data source is ndarray, array() will still copy a copy, occupying new memory, but not When changing the dtype, asarray() does not.
def fromfunction(function, 1 shape, **kwargs): means to define a function, this place should be more important.
Zero arrays, 1 arrays, empty arrays, unit arrays, diagonal arrays, constant arrays, etc. are all basic operations and are often used in operations. arange() function, linspace() function, logspace() function, numpy.random.rand() returns an array of random numbers in [0,1).
Use a dictionary to define the structure:
personType = np.dtype({ 'names': ['name','age'], 'formats': ['U30','i8']}) Use a list containing multiple tuples To define the structure: personType = np.dtype([('name','U30'), ('age','i8'), ('weight','f8')]) a = np.array([( 'Liming', 24, 63.9), ('Mike', 15, 67.), ('Jan', 34, 45.8)], dtype=personType) the attribute of the array numpy.ndarray.ndim returns the dimension of the array, numpy .ndarray.shape represents the dimension of the array, numpy.ndarray.size is the total amount of all elements in the array, numpy.ndarray.dtype is the element type of the ndarray object, and numpy.ndarray.itemsize returns the value of each element in the array in bytes size.






Guess you like

Origin blog.csdn.net/m0_49978528/article/details/109250173