I'd like to replace the last N columns of a Numpy array by zeroes.
a = numpy.tile([1,2,3,4], (4,1))
array([[1, 2, 3, 4],
[1, 2, 3, 4],
[1, 2, 3, 4],
[1, 2, 3, 4]])
To replace the last, I do:
a[:,-1] = 0
To replace the last 2, I would do
a[:,-2:-1] = 0
but this only replaces the penultimate column
array([[1, 2, 0, 4],
[1, 2, 0, 4],
[1, 2, 0, 4],
[1, 2, 0, 4]])
Can you please explain why? What should I do to get what I want?
Thanks