Numpy Fundamentals | Indexing & Slicing
🎓 Master AI from Zero to Advanced: https://ailearninghub.io ------------------------- In this video, you’ll master indexing and slicing in NumPy—one of the most powerful features for efficient data selection and manipulation. We’ll start with one-dimensional arrays: accessing elements by positive and negative indices, using slice notation (start, stop, step), and grabbing every other element. Then you’ll learn how to work with two- and three-dimensional arrays: selecting rows, columns, sub-matrices, and layers. Finally, we’ll cover Boolean indexing (filtering with conditions), combining logical operators, and advanced “fancy” indexing to pull out arbitrary elements or diagonals. By the end, you’ll be able to navigate and extract exactly the data you need from any NumPy array. To try all these examples without installing Python locally, head over to Google Colab: Introduction to Google Colab: https://youtu.be/FXKMmilL70w Create a new Google Colab Notebook: https://colab.research.google.com/#create=true Table of Contents: 0:00 Introduction to NumPy Array Structures 0:08 Why Use NumPy Over Python Lists 0:15 Importance of Indexing & Slicing 0:22 Importing NumPy as np 0:30 One-Dimensional Array Overview 0:37 1D Indexing & Slicing Basics 0:44 Accessing 1D Elements by Index 0:50 Zero-Based & Negative Indexing 0:51 Creating a 1D Array with np.array 1:24 Viewing a 1D Array 1:34 Accessing First & Second Elements 1:57 Negative Indexing for Last Element 2:10 Slicing 1D Arrays: start:stop:step 2:33 Selecting a Specific Slice Range 3:24 Implicit Start or End in Slicing 5:03 Step Slicing: Every Other Element 5:08 Two-Dimensional Array (Matrix) Overview 5:26 Creating a 2D Array with np.array 5:56 Viewing a 2D Array 6:06 Indexing Elements in 2D Arrays 7:37 Comma-Separated Indexing in 2D 8:15 Slicing Subarrays in 2D 9:45 Extracting Specific 2D Subarrays 11:26 Multi-Dimensional Arrays (3D) Overview 11:39 Creating a 3D Array with np.array 13:35 Indexing Elements in 3D Arrays 15:19 Slicing Layers in 3D Arrays 16:05 Multi-Layer Slicing in 3D Arrays 17:00 Boolean Indexing Introduction 17:46 Filtering with Conditions 18:41 Combining Conditions (and, or) 18:47 Selecting Even Numbers 19:16 Selecting Odd Numbers 20:36 OR Condition 21:01 Using Boolean Arrays to Index 21:46 Advanced Integer (“Fancy”) Indexing 22:54 Fancy Indexing for Diagonals ------------------------- Social channels: 🐦Twitter: https://twitter.com/dankornas 🌍LinkedIn: https://www.linkedin.com/in/daniel-kornas/ 🕵Facebook: https://www.facebook.com/dankornas 📱Instagram: https://www.instagram.com/dankornas 🧵 Threads: https://www.threads.net/@dankornas ------------------------- 📚 AI Books 📚 Introduction to Generative AI 👉 https://shorturl.at/3dSQz Build a Large Language Model (From Scratch) 👉 https://shorturl.at/EFv4j *I use affiliate links on the products that I recommend. I may earn a purchase commission or a referral bonus from the usage of these links.
Download
1 formatsVideo Formats
Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.