# Numpy second slice

In the optimisation methods ex 2 there is a hint as below
ππππ_πππ‘πβ_π=π βπ’πππππ_π[:,π:π]
Numpy array slicing method is ;-
Array_sub = array[start : stop : step , start : stop : step , etc ] where the comma delineates between separate slices of the object array.
Why does the hint suggest we get data from the second slice rather than the first?
I do notice that if I remove the first colon and comma then the routine fails,
Regards
Ian

Got it. You are combining indexing and slicing, which requires the βempty sliceβ at the start.
Ian

The point is that there are two dimensions, right? We want the full width of the βrowsβ dimension, but only a subset of the column dimension. Thatβs because the columns are the samples and we want a subset of them. So itβs not an βempty sliceβ: itβs the full range of the index. The way you say that is β:β, in other words a range with no start and no end: so in python that means take everything. The range is from the earliest possible start to the latest possible end.

Thanks Paul
That explains a lot.
Ian