Another reason that numpy is so useful is because of its extensive implementation for array operations and math. Numpy has tons of functions that save us tons of time and can perform operations very quickly
The following operations are supported on numpy arrays. They perform whats known as element-wise operations.
- addition: + or np.add()
- subtraction: - or np.subtract()
- multiplication: * or np.multiply()
- division: / or np.divide()
- square root: np.sqrt()
To take the dot product of two arrays we can use .dot().
When we take the dot product of two arrays of the same size we get a scalar. Otherwise we get what's called an inner product.
To transpose a matrix or array we can use .T.
To take the sum of an array we can use np.sum(axis=).
To read more about numpy and see everything it has to offer click here.