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.
Find shapes of NumPy arrays and reshape - Python Tutorial
From the course: Python Functions for Data Science
Find shapes of NumPy arrays and reshape
- [Instructor] As you work with numpy arrays, you may need to check the shape of a numpy array, to find out whether it is one dimensional or multidimensional, the number of dimensions it has, and the number of items it has in each dimension. And at times you may need to reshape a numpy array in order to create a new numpy array with the same items, but with a different shape. For example, say that I have a variable named array0 containing a numpy array. To check its shape, I can call its shape attribute. It would look like this. When I ran that cell, I got a tuple containing zero, which indicates that array0 is empty and has no items. Now, say that I have a variable named array1 containing another numpy array. To check its shape, I can call its shape attribute. It would look like this. When I ran that cell, I got a tuple containing five, which indicates that array1 is one dimensional and has five items. Next, say that I…
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)
-
-
-
-
-