Basic Numpy Array: 👓

Numpy arrays come with two different kind: vetrices and matrices. Vetrices are strictly 1-D array, while Matrices are 2-D(note: 2-D array could contains one row and one column). In this section I want to cover on basics implementation of Numpy array and a couple of functions.

import numpy as np

This is how numpy displays a 2-D array. In this case, the shape of the 2-D array above shown is (3, 3). 3 for its row and 3 for its column.

shape: shape is a descriptor to return the number of row & column in a tuple from the given np array.

reshape: a function that assigns a new shape for your np array

Note : when you try to reshape your 2d array, please pay attention on how many elements in your array.

Example:

When you have a (3, 3) 2d array with 9 elements altogether, it won’t be possible if you reshape into (3, 5) or any number larger than 3 for its column. But in the other hand it is still possible to reshape into (9, 1), nine rows and one column.

numpy_array.reshape(3, 5)

will give you: