[SciPy-user] array slice problems ...

Sebastian Stephan Berg se.berg at stud.uni-goettingen.de
Sun Mar 16 09:54:53 EDT 2008


Hello,

maybe I am doing something wrong or misunderstood it, but with your code
I get:

a_array = [[1], [2], [3], [4]]

(so the second part does not actually work). While I think you want the
array to be shaped [[1,2,3,4]]?
But anyways, that second array can be sliced with [:,1:3] as you want
giving you all of the first dimension and from the second dimension only
items 1:3. So I think what you want is simply not using two seperate
slicings. Another example:

a = array([[1,2,3,4], [2,3,4,5]])
a[:,1:3] giving array([[2,3], [3,4]])

This of course does only work with arrays and not with lists.

Regards,

Sebastian




More information about the SciPy-User mailing list