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
From the course: NumPy Essential Training: 1 Foundations of NumPy
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…
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
-
-
-
-
Array types and conversions between types4m 25s
-
(Locked)
Multidimensional arrays3m 7s
-
(Locked)
Creating arrays from lists and other Python structures3m 36s
-
(Locked)
Intrinsic NumPy array creation5m 33s
-
(Locked)
Creating arrays filled with constant values4m 41s
-
(Locked)
Finding the shape and size of an array2m 50s
-
-
-
-