Python NumPy »
My Coding >
Programming language >
Python libraries and packages >
Python NumPy (Page: 1)
Go to Page:
NumPy 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 array
Initialize NumPy array with list
It is possible to convert list into NumPy array
Initialize NumPy array with arranged values
arrange() 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 array
It 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 array
zeros() - 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 array
ones() - function to create array filled with float(1). Use dtype = np.int32 to fill with integer values
Randomply filled NumPy array
rand() - 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 array
In 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
eye() - interesting, why eye? Create identity matrix with specified size
Creating structural array
Structural 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.