Array routines
In this section, we will deal with most operations on arrays. We will classify them into four main categories:
- Routines to create new arrays
- Routines to manipulate a single array
- Routines to combine two or more arrays
- Routines to extract information from arrays
The reader will surely realize that some operations of this kind can be carried out by methods, which once again shows the flexibility of Python and NumPy.
Routines to create arrays
We have previously seen the command to create an array and store it to a variable A
. Let's take a look at it again:
>>> A=numpy.array([[1,2],[2,1]])
The complete syntax, however, writes as follows:
array(object,dtype=None,copy=True,order=None, subok=False,ndim=0)
Let's go over the options: object
is simply the data we use to initialize the array. In the previous example, the object is a 2 x 2 square matrix; we may impose a datatype with the dtype
option. The result is stored in the variable A
. If copy
is True
, the returned object...