Skip to main content

NumPy Accessing Arrays

Body

In this tutorial you will learn:

  • Access NumPy Array
  • Accessing Arrays with Negative Index

Access NumPy Array

The elements of NumPy Array can be accessed by indexing, it’s very similar to accessing an element in an array. We already know that the index of an array start with zero.

Example

Access a 1-D array is very simple and straight forward we just need to pass the index in square brackets and print the value.

  1. import numpy as np
  2. arr = np.array([10, 8, 7, 2])
  3. print("** NumPy Show 1-D array access**”)
  4. print("Third element is: ", arr[2])

In order to access 2-D array using

Add new comment

Screenshot