From the course: Python Functions for Data Science

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Select items or groups of items from NumPy arrays

Select items or groups of items from NumPy arrays - Python Tutorial

From the course: Python Functions for Data Science

Start my 1-month free trial

Select items or groups of items from NumPy arrays

- [Instructor] Oftentimes when you work with NumPy arrays, you will want to access specific subsets of the data stored in those NumPy arrays. I will be walking through some examples to demonstrate how to do that. Let's say I have a variable named array0 containing a one-dimensional NumPy array of integers zero to four, including zero and four. Now say I want to select the item at index one from array0. To do this, I can use a pair of square brackets and pass in the index. It would look like this. Next, say I want to select the items at indices one to three, inclusive, from array0. To do this, I can slice array0. I'll use a pair of square brackets and pass in one as a starting index, which has included, a colon, and four as the ending index, which is excluded. It would look like this. Then say I want to select the items at indices zero to three from array0. To do this, I'll again slice array0. I'll use a pair of square…

Contents