Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Access 2-D and 3-D Arrays | Indexing and Slicing
NumPy in a Nutshell
course content

Course Content

NumPy in a Nutshell

NumPy in a Nutshell

1. Getting Started with NumPy
2. Dimensions in Arrays
3. Indexing and Slicing
4. Important Functions

book Access 2-D and 3-D Arrays

Let's have a look at an example of a 2-D array with axis numbering:

Let's have a look at an example of indexing (both positive and negative) in 2-D arrays:

Let's examine the syntax of slicing: array[start_row: end_row: step_row, start_column: end_column: step_column], where:

  • start_row is the index from which row slicing begins;
  • end_row is the index where row slicing stops (note that this index is not included);
  • step_row is the parameter that specifies the intervals between row indices;
  • start_column is the index from which column slicing starts;
  • end_column is the index where column slicing ends (note that this index is not included);
  • step_column is the parameter that determines the intervals between column indices.

Now, let's refer to the following image:

Let's have a look at an example of a 3-D array with axis numbering:

Task

Consider the following array: [[6, 5, 7, 8], [65, 2, 7, 9]].

  1. Retrieve the fourth element from the first part of the array [6, 5, 7, 8], and the first element from the second part of the array [65, 2, 7, 9].
  2. Multiply the obtained elements together.
  3. Display the product of the obtained elements.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 3
toggle bottom row

book Access 2-D and 3-D Arrays

Let's have a look at an example of a 2-D array with axis numbering:

Let's have a look at an example of indexing (both positive and negative) in 2-D arrays:

Let's examine the syntax of slicing: array[start_row: end_row: step_row, start_column: end_column: step_column], where:

  • start_row is the index from which row slicing begins;
  • end_row is the index where row slicing stops (note that this index is not included);
  • step_row is the parameter that specifies the intervals between row indices;
  • start_column is the index from which column slicing starts;
  • end_column is the index where column slicing ends (note that this index is not included);
  • step_column is the parameter that determines the intervals between column indices.

Now, let's refer to the following image:

Let's have a look at an example of a 3-D array with axis numbering:

Task

Consider the following array: [[6, 5, 7, 8], [65, 2, 7, 9]].

  1. Retrieve the fourth element from the first part of the array [6, 5, 7, 8], and the first element from the second part of the array [65, 2, 7, 9].
  2. Multiply the obtained elements together.
  3. Display the product of the obtained elements.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 3
toggle bottom row

book Access 2-D and 3-D Arrays

Let's have a look at an example of a 2-D array with axis numbering:

Let's have a look at an example of indexing (both positive and negative) in 2-D arrays:

Let's examine the syntax of slicing: array[start_row: end_row: step_row, start_column: end_column: step_column], where:

  • start_row is the index from which row slicing begins;
  • end_row is the index where row slicing stops (note that this index is not included);
  • step_row is the parameter that specifies the intervals between row indices;
  • start_column is the index from which column slicing starts;
  • end_column is the index where column slicing ends (note that this index is not included);
  • step_column is the parameter that determines the intervals between column indices.

Now, let's refer to the following image:

Let's have a look at an example of a 3-D array with axis numbering:

Task

Consider the following array: [[6, 5, 7, 8], [65, 2, 7, 9]].

  1. Retrieve the fourth element from the first part of the array [6, 5, 7, 8], and the first element from the second part of the array [65, 2, 7, 9].
  2. Multiply the obtained elements together.
  3. Display the product of the obtained elements.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Let's have a look at an example of a 2-D array with axis numbering:

Let's have a look at an example of indexing (both positive and negative) in 2-D arrays:

Let's examine the syntax of slicing: array[start_row: end_row: step_row, start_column: end_column: step_column], where:

  • start_row is the index from which row slicing begins;
  • end_row is the index where row slicing stops (note that this index is not included);
  • step_row is the parameter that specifies the intervals between row indices;
  • start_column is the index from which column slicing starts;
  • end_column is the index where column slicing ends (note that this index is not included);
  • step_column is the parameter that determines the intervals between column indices.

Now, let's refer to the following image:

Let's have a look at an example of a 3-D array with axis numbering:

Task

Consider the following array: [[6, 5, 7, 8], [65, 2, 7, 9]].

  1. Retrieve the fourth element from the first part of the array [6, 5, 7, 8], and the first element from the second part of the array [65, 2, 7, 9].
  2. Multiply the obtained elements together.
  3. Display the product of the obtained elements.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Section 3. Chapter 3
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
some-alt