How to Slice a NumPy Array


In this example, we will learn how to slice a NumPy array by giving a start index but omitting an end index in Python.

Source Code

import numpy as np

n = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])

# slice elements from index 3 to the end of the array
print(n[3:])

Output:

[ 4  5  6  7  8  9 10]
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Advertisement