From the course: Python Functions for Data Science
Indices of min and max values in NumPy arrays - Python Tutorial
From the course: Python Functions for Data Science
Indices of min and max values in NumPy arrays
- [Narrator] When working with NumPy arrays, you may need to locate where the minimum and maximum values lie. In other words, you may need to find the indices of the minimum and maximum values. This is where the argmin and argmax functions that are specific to NumPy arrays come in. For example, let's say that I have a variable named array_random containing a NumPy array of 20 random integers from 1 to 50. To find the index of the minimum value in this NumPy array, I can call the argmin function on array_random. It would look like this. I'll go ahead and run this cell. As you can see, the index of the minimum value is 13. Now to find the index of the maximum value in array_random, I can call the argmax function on array_random. It would look like this. I'll go ahead and run this cell. As you can see, the index of the maximum value is 19. There. Now that you've seen how the argmin and argmax function specific to NumPy arrays work, you can use them to find the indices of the minimum and maximum values in your data.
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)
-
-
-
-
-