How can I sum an interval of elements on an array in python / numpy ?
For example, in matlab it is possible something like this:
y= ones(10,20);
y(1:5,:) = 2;
for k = 1: 10
psum(k) = sum(y((1:3),k));
end
But sum function from numpy doesn’t suport “1:3”
Thanks !
Probably something like this:
A simpler example:
prints
16, the sum of the middle three elements.