From the course: NumPy Essential Training: 1 Foundations of NumPy

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Finding the shape and size of an array

Finding the shape and size of an array

- [Instructor] Knowing the three bits such as dimension, datatype, shape and size is very important when you're doing computations with ndarrays. As we have learned, an array is a container with a fixed size that has elements of the same type, the shape of the array defines the number of elements in each dimension. It is represented as a topple of non-negative integers. Let's learn how to find the shape of ndarray. We'll import numpy as NP and create free ndarrays and call them first arr, second arr and third arr. For first arr, we'll use an arrange function and pass 20 as an argument to get to one dimensional array. For second array, second arr, we'll use the list-based function and pass two topples 1, 2 and 10, 20 and the third argument, 10 to get the two dimensional array. Finally, for the third arr, we'll use the full function and pass topple 2,2,2 and 10 as the second argument to get a free dimensional array of tens. Shape function, as its name says, gives us the number of…

Contents