NumPy array object
NumPy has a multi-dimensional array object called ndarray
. It consists of two parts:
The actual data
Some metadata describing the data
The majority of array operations leave the raw data untouched. The only aspect that changes is the metadata.
We have already learned, in the previous chapter, how to create an array using the arange
function. Actually, we created a one-dimensional array that contained a set of numbers. ndarray
can have more than one dimension.
The NumPy array is in general homogeneous (there is a special array type that is heterogeneous)—the items in the array have to be of the same type. The advantage is that, if we know that the items in the array are of the same type, it is easy to determine the storage size required for the array.
NumPy arrays are indexed just like in Python, starting from 0
. Data types are represented by special objects. These objects will be discussed comprehensively in this chapter.
We will create an array with the arange
function again...