import numpy as np
Slicing 1-D NumPy ArraysΒΆ
Slicing extracts a portion of an array using the start:stop:step syntax. Like Python lists, the start index is inclusive and the stop index is exclusive. Omitting start defaults to 0; omitting stop defaults to the end; omitting step defaults to 1. Negative indices count from the end of the array. Slicing returns a view (not a copy), so modifications to the slice affect the original array. This is a deliberate design choice for memory efficiency when working with large datasets.