NumPy is a free Python library equipped with a collection of complex mathematical operations suitable for processing statistical data. It can be imported into Python as follows:
import numpy as np# The np label can be used to access the numpy library
Data manipulation is a core component in data sciences and machine learning. In the case of machine learning, the system takes in a huge amount of data and trains itself to make accurate predictions. Naturally, it would need to perform arithmetic operations on numerical data to produce something meaningful. This is where NumPy comes into play.
The main data structure in NumPy is the NumPy array. All the data is stored in arrays. NumPy provides a vast repertoire of mathematical and statistical operations which can be performed on these arrays.
import numpy as nparr_1 = np.array([1, 2, 3, 4, 5, 6])fltr = [True, False, True, False, True, False]# filtering elements of an arrayarr_2 = arr_1[fltr]print(arr_2)