From the course: NumPy Essential Training: 1 Foundations of NumPy
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Indexing and slicing
From the course: NumPy Essential Training: 1 Foundations of NumPy
Indexing and slicing
- One of the biggest advantages of NumPy is manipulation of large numbers of values without the need to write inefficient by the loops. To achieve this, we have to be able to refer to elements of the arrays in many different ways. Let's learn two ways to access elements in array. Indexing, and slicing. We've wouldn't benefit from using multidimensional arrays if we couldn't access elements between them and update them when it's needed. This is called array indexing. To index arrays, we use square brackets. Opening bracket begins the index and closing bracket ends it. Inside the square brackets, we write which elements of the array we want NumPy to return or assign. It's called subscript. You have already experienced indexing in the previous chapter. Let's see a couple more advanced examples on how to access elements of a multidimensional array. Let's jump into our first example and see how to access elements in two-dimensional and three-dimensional arrays. We have already imported…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.