DEV Community

TechPlygrnd
TechPlygrnd

Posted on

NumPy Tutorial #4: Array Slicing

How can you slicing a NumPy array? The concept is same as python list implementation. Let us see how to implement slicing.

First of all, let's create a NumPy array

import numpy as np

list_of_number = [6, 7, 8, 9, 10]

arr = np.array(list_of_number)
Enter fullscreen mode Exit fullscreen mode

To create a slice of [6, 7, 8] from the array, you can run this code

print(arr[0:3])
Enter fullscreen mode Exit fullscreen mode

you will get this output

[6 7 8]
Enter fullscreen mode Exit fullscreen mode

That is how you can slice an array to create a set of new sliced array. Thank you for reading this blog and have a good day!

Top comments (0)