Python NumPy »
|
My Coding >
Programming language >
Python >
Python libraries and packages >
Python NumPy
Python NumPy (Page: 1)Go to Page: NumPy initializingNumPy is the fundamental package for array computing with Python. In this section I will describe basic manipulations with NumPy array Initialization of one-dimensional NumPy arrayInitialize NumPy array with listIt is possible to convert list into NumPy array
Initialize NumPy array with arranged valuesarrange() is almost identical to range(), but can work with float and integer values and it is designed t fill arrays with the range of values
Initialization of two-dimensional NumPy arrayIt is possible to convert list of lists into NumPy array. Furthermore, you can initialize any dimensional array, but it is important to be careful about list sizes.
We can create pre-filled array Zero filled NumPy arrayzeros() - function to create array filled with zeroes
To fill this array with int(0) values, it is necessary to specify this type
Ones filled NumPy arrayones() - function to create array filled with float(1). Use dtype = np.int32 to fill with integer values
Randomply filled NumPy arrayrand() - function to create array filled with random values on range [0., 1.). For example, wee need to create an array 5 rows with 3 column each, filled with random values in range from -3 to 10
Non-initialized NumPy arrayIn fact, this array will be filled not with non-initialized value, but it will be filled with some random values. The function empty() works much faster than previous, but values can be any
Identity matrixeye() - interesting, why eye? Create identity matrix with specified size
Creating structural arrayStructural array in NumPy is kind of analogue of one level dictionary. It is proper array, but it is possible to refer to some data by names of these rows or columns, rather than by its numbers.
|
Last 10 artitles
9 popular artitles
|
© 2020 MyCoding.uk -My blog about coding and further learning. This blog was writen with pure Perl and front-end output was performed with TemplateToolkit. |