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 - Python Tutorial
From the course: Python Functions for Data Science
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…
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.
Contents
-
-
-
-
-
(Locked)
Create NumPy arrays in Python5m 30s
-
(Locked)
Minimum and maximum values in NumPy arrays51s
-
Indices of min and max values in NumPy arrays1m 4s
-
(Locked)
Find shapes of NumPy arrays and reshape4m 23s
-
(Locked)
Select items or groups of items from NumPy arrays4m 35s
-
(Locked)
Arithmetic operations on NumPy arrays2m 5s
-
(Locked)
Scalar operations on NumPy arrays1m 33s
-
(Locked)
Statistical operations on NumPy arrays56s
-
(Locked)
Other operations on NumPy arrays2m 58s
-
(Locked)
-
-
-
-
-