What is NumPy?

Share

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

Numerical data in machine learning

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.

Basic functions of NumPy

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.

svg viewer

Code

import numpy as np
arr_1 = np.array([1, 2, 3, 4, 5, 6])
fltr = [True, False, True, False, True, False]
# filtering elements of an array
arr_2 = arr_1[fltr]
print(arr_2)
Copyright ©2024 Educative, Inc. All rights reserved