I have an array like this:
1 2 3 4
2 3 4 5
3 4 5 6
I want to split it and sum the sub-arrays to get a smaller array.
For example, i want to split it given the following group sizes: [[2, 1], [1, 3]]
1 | 2 3 4
2 | 3 4 5
---------
3 | 4 5 6
The result should be:
1+2 2+3+4+3+4+5
3 4+5+6
3 21
3 15
Is there an efficient way to do this with numpy functions instead of for loops? I need to do it on high dimensional arrays. Thanks!