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

Find shapes of NumPy arrays and reshape - Python Tutorial

From the course: Python Functions for Data Science

Start my 1-month free trial

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…

Contents