Skip to main content
MahiDev — Learn. Build. Become AI-ready.

Module 23

NumPy

Create, index, filter, reshape, and analyze numeric arrays with NumPy, the base library for data science and machine learning.

Intermediate7 hours 55 min19 lessons

01

What Is NumPy

Meet NumPy and its ndarray: one type per array, math on every element without a loop, less memory than a list, and easy reshaping.

Intermediate25 min

02

Array Attributes

Read an array with ndim, shape, size, dtype, and itemsize, then change its type with astype and its layout with the shape attribute.

Intermediate25 min

03

Creating Arrays

Build arrays without typing every value: arange, zeros, ones, full, linspace, identity, eye, and joining arrays with hstack and vstack.

Intermediate25 min

04

Random Arrays

Generate random arrays with randint, rand, uniform, randn, normal, and choice, then reorder values with shuffle and permutation.

Intermediate25 min

05

Indexing

Read and change single values in 1-D, 2-D, and 3-D arrays with positive and negative indices, and see what an invalid index raises.

Intermediate25 min

06

Slicing

Slice ranges of values from 1-D, 2-D, and 3-D arrays with begin, end, and step, including reversed steps and whole rows or columns.

Intermediate25 min

07

Advanced Indexing

Pick scattered values with index lists: chosen positions in 1-D, row and column pairs in 2-D, sub-grids with ix_, and positions in 3-D arrays.

Intermediate25 min

08

Copy and View

Tell a copy from a view with base and shares_memory, see why a slice changes its original, and pick between flatten and ravel.

Intermediate25 min

09

Sorting and Comparing

Sort 1-D and 2-D arrays with np.sort and an axis, sort in place, find the sort order with argsort, and compare arrays element by element.

Intermediate25 min

10

Filtering Arrays

Filter arrays with boolean masks, combine conditions with & and |, find or replace values with where, keep them with extract, and handle NaN.

Intermediate25 min

11

Append, Insert, and Delete

Add values with np.append and np.insert and remove them with np.delete, on 1-D arrays and on whole rows or columns of 2-D arrays.

Intermediate25 min

12

Splitting Arrays

Cut arrays into pieces with split, array_split, hsplit, vsplit, and dsplit, using equal parts, uneven parts, or chosen cut points.

Intermediate25 min

13

Iterating Arrays

Loop over 1-D, 2-D, and 3-D arrays, reach every value with nditer, get each index with ndenumerate, and know when a loop is not needed.

Intermediate25 min

14

Arithmetic and Broadcasting

Add, subtract, multiply, divide, and raise arrays element by element, mix in single values with broadcasting, and multiply matrices with @.

Intermediate25 min

15

Statistics

Summarize arrays with max, min, argmax, mean, median, variance, and standard deviation, for the whole array or per row and column.

Intermediate25 min

16

Sums, Products, and Rounding

Use NumPy universal functions for sums, running totals, products, differences, rounding, and the LCM and GCD of whole arrays.

Intermediate25 min

17

Unique Values and Sets

Find unique values with counts and first positions, unique rows and columns, and combine arrays with union, intersection, and difference.

Intermediate25 min

18

Linear Algebra

Compute dot, inner, and outer products, transpose and trace, then use np.linalg for determinants, inverses, and solving linear equations.

Intermediate25 min

19

Saving and Loading Arrays

Save arrays to text and CSV with savetxt, read them with loadtxt and genfromtxt, keep exact arrays in .npy and .npz files, and load JSON.

Intermediate25 min