Working with arrays using NumPy
What is NumPy
NumPy (short for Numerical Python) is an Open Source Python library used for working with numerical data in Python. It provides an efficient way to store and make operations on big datasets. According to the NumPy User Guide:
"It is a Python library that provides a multidimensional array object, various derived objects (such as masked arrays and matrices), and an assortment of routines for fast operations on arrays, including mathematical, logical, shape manipulation, sorting, selecting, I/O, discrete Fourier transforms, basic linear algebra, basic statistical operations, random simulation and much more."
NumPy arrays, similar but much more powerful than Python Lists, are at the core of many libraries in the Python Data Science ecosystem.
In this post we'll explore the following 5 NumPy functions:
- function 1: np.array
- function 2: np.zeros
- function 3: np.ndarray.size
- function 4: np.transpose
- function 5: np.linspace
Let's beging by importing the python libraries we'll use:
!pip install jovian --upgrade -q
import numpy as np
import jovian
WARNING: You are using pip version 20.2.3; however, version 20.2.4 is available.
You should consider upgrading via the '/opt/conda/bin/python3.7 -m pip install --upgrade pip' command.
jovian.commit(project='numpy-array-operations')
[jovian] Attempting to save notebook..
[jovian] Detected Kaggle notebook...
[jovian] Please enter your API key ( from https://jovian.ml/ ):
API KEY: ········
[jovian] Uploading notebook to https://jovian.ml/letrayruido/numpy-array-operations
# List of functions explained
function1 = np.array
function2 = np.zeros
function3 = np.ndarray.size
function4 = np.transpose
function5 = np.linspace
Function 1 - np.array
This function creates an array with the features specified in the parameters.