Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
3-D Arrays | Dimensions in Arrays
course content

Contenido del Curso

NumPy in a Nutshell

3-D Arrays3-D Arrays

With three-dimensional arrays, everything is quite clear and logical. These arrays consist of elements that are two-dimensional arrays.

Let's practice to make it easier to understand.

Here's an example of how we can create a 3-D array with four 2-D arrays, each containing three 1D arrays with 2 elements:

Let's now take a look at the visualization of this array:

Example

Our 3D array is 4x3x2, hence why we have a rectangular parallelepiped with sides equal to 4, 3 and 2, respectively. The innermost 1D arrays lie along the axis 2 (e.g., [1, 2] or [4, 3]) where each small cube with side equal to 1 is a particular element (number).

Basically, all the elements of a 3D array are stored inside these innermost 1D arrays. The rectangular parallelepiped is just a visual representation for us to make things clear. The total number of elements (small cubes) is equal to 24 (the volume of the rectangular parallelepiped), which 4 * 3 * 2.

Note

Since its a 2D visualization of a 3D object, we cannot display and see here all the elements.

Time to test your strength!

Tarea

  1. You need to create two arrays:
    • the first one is a 2-D array containing two arrays with the values: 1, 5, 2 and 34, 2, 7;
    • the second one is a 3-D array (use only a single to create this array) containing two 2-D arrays, both of which include two arrays with the values 5, 3, 8 and 6, 1, 9.
  2. Display these arrays on the screen: first arr_1, then arr_2.

¿Todo estuvo claro?

Sección 2. Capítulo 4
toggle bottom row
course content

Contenido del Curso

NumPy in a Nutshell

3-D Arrays3-D Arrays

With three-dimensional arrays, everything is quite clear and logical. These arrays consist of elements that are two-dimensional arrays.

Let's practice to make it easier to understand.

Here's an example of how we can create a 3-D array with four 2-D arrays, each containing three 1D arrays with 2 elements:

Let's now take a look at the visualization of this array:

Example

Our 3D array is 4x3x2, hence why we have a rectangular parallelepiped with sides equal to 4, 3 and 2, respectively. The innermost 1D arrays lie along the axis 2 (e.g., [1, 2] or [4, 3]) where each small cube with side equal to 1 is a particular element (number).

Basically, all the elements of a 3D array are stored inside these innermost 1D arrays. The rectangular parallelepiped is just a visual representation for us to make things clear. The total number of elements (small cubes) is equal to 24 (the volume of the rectangular parallelepiped), which 4 * 3 * 2.

Note

Since its a 2D visualization of a 3D object, we cannot display and see here all the elements.

Time to test your strength!

Tarea

  1. You need to create two arrays:
    • the first one is a 2-D array containing two arrays with the values: 1, 5, 2 and 34, 2, 7;
    • the second one is a 3-D array (use only a single to create this array) containing two 2-D arrays, both of which include two arrays with the values 5, 3, 8 and 6, 1, 9.
  2. Display these arrays on the screen: first arr_1, then arr_2.

¿Todo estuvo claro?

Sección 2. Capítulo 4
toggle bottom row
some-alt