I have a nx1 array, a:
array([[0],
[0],
[0]])
when I slice it with
a[:-1,0]
it becomes:
a([0,0])
and I’m not able to use it in plot (now the dimensions are wrong, even though the length is correct). I’ve tried
a[:-1,0].T
and
transpose(a[:-1,0])
to no avail.
How do I slice without changing the shape? (I want to keep it in column form)
Say
a = numpy.zeros((3,1)), thenwill give you a column vector.
When slicing a numpy array, you have to distinguish between adressing the content of a column, e.g.
a[:,0], and adressing the column itself, e.g.a[:,0:1]or – in this case –a[:,:].