USD ($)
$
United States Dollar
Euro Member Countries
India Rupee
د.إ
United Arab Emirates dirham
ر.س
Saudi Arabia Riyal

NumPy Basics (Arrays, Operations)

Lesson 24/35 | Study Time: 60 Min

When working with data in AI and machine learning, you constantly deal with large collections of numbers — pixel values, sensor readings, model weights, and dataset features.

Python lists can store numbers, but they are slow and limited for mathematical operations. NumPy solves this.

NumPy (Numerical Python) is a foundational library that provides fast, efficient multi-dimensional arrays and a rich set of mathematical operations. It is the backbone of almost every data science and AI library, including Pandas, Scikit-learn, and TensorFlow.

Installing and Importing NumPy

NumPy comes pre-installed with Anaconda. If needed, install it using pip:

Import it into your script using the standard alias np:

NumPy Arrays

The core of NumPy is the ndarray (n-dimensional array) — a grid of values, all of the same data type, that supports fast mathematical operations.

Creating Arrays

Built-in Array Creation Functions


Array Properties

Understanding the shape and structure of your array is critical when working with datasets and AI models.




Indexing and Slicing

Accessing elements in NumPy arrays works similarly to lists but extends naturally to multiple dimensions.


Array Operations
One of NumPy's greatest strengths is that mathematical operations apply to every element automatically — no loops needed.


Arithmetic Operations

Scalar Operations


Operations with a single number (scalar) are applied to every element — this is called broadcasting.

Statistical Operations

NumPy provides fast statistical functions that are heavily used in data analysis and AI preprocessing.




Reshaping Arrays
Reshaping changes the structure of an array without changing its data, essential when preparing data for AI models.


Boolean Filtering

NumPy supports filtering arrays using conditions — a powerful feature for data cleaning in AI.


NumPy vs Python Lists


For any numerical or AI task, NumPy arrays are always the better choice over plain Python lists.

Sales Campaign

Sales Campaign

We have a sales campaign on our promoted courses and products. You can purchase 1 products at a discounted price up to 15% discount.