NumPy will be the linear algebra library we will use. We will soon get into its functionalities - it has a lot of them - but here we are going to discuss a NumPy array. A NumPy array is used in a lot of plotting functionalities, and we'll be converting data from a Pandas Dataframe to a NumPy array when we reach more of the core ML parts.
First, let's consider a list.
a = [1, 2, 3, 4, 5]
We can make this a NumPy array through the following function call:
numpy_arr = np.array(a)
When we want to convert a dataframe column to a NumPy Array, we can use the np.asanyarray **function:
numpyArray = np.asanyarray(df[["col"]])
If a is a numpy array,
a.size
produces the number of elements in the numpy array and
a.shape
produces a tuple with the size of each dimension.
The NumPy array has a fixed size, meaning we cannot insert or delete elements from it. However, we can still change the already existing elements of a numpy array. For instance, if we have an array called numpyArray and $0<n<$ len(numpyArray),
numpyArray[n] = m