I have a 3-D NumPy array with shape (100, 50, 20). I was trying to slice the third dimension of the array by using the index, e.g., from 1 to 6 and from 8 to 10.
I tried the following code, but it kept reporting a syntax error.
newarr [:,:,1:10] = oldarr[:,:,[1:7,8:11]]
[1:7,8:11]is an invalid use of slices. The error was caught by the interpreter, but it also has no meaning tonumpy. That's a discontinuous set of locations, which has to be enumerated as shown in the answer.