1a[start:stop] # items start through stop-1
2a[start:] # items start through the rest of the array
3a[:stop] # items from the beginning through stop-1
4a[:] # a copy of the whole array
5Example:
6>>> a = [1, 2, 3, 4, 5, 6, 7, 8]
7>>> a[1:4]
8[2, 3, 4]
1#slicing arrays:
2#generic sampling is done by
3#arr[start:end] -> where start is the starting index and end is ending idx
4>>> import numpy as np
5>>> arr = np.array([1,2,3,4,5])
6>>> print(arr[1:5]) #starting idx 1 to ending index 4
7[2 3 4 5]#it will print from starting idx to ending idx-1
8
9#if you leave the ending index blank it will print all
10#from the starting index till end
11>>> arr = np.array([2,6,1,7,5])
12>>> print(arr[3:])
13[7 5]
14>>> print(arr[:3]) #if you leave the starting index blank it will print from 0 index to the ending idx-1\
15[2 6 1]
16>>> print(arr[:])
17[2 6 1 7 5]
18#leaving both the index open will print the entire array.
19
20##########STEP slicing########
21#if you want to traverse by taking steps more than 1
22#we use step slicing in that case
23#syntax for step slicing is : arr[start:end:step]
24>>> arr = np.array([2,6,1,7,5,10,43,21,100,29])
25>>> print(arr[1:8:2])#we have taken steps of two
26[ 6 7 10 21]
27
28
29
30
31