[英]Using numpy, how can I generate an array where the value at each index is the sum of the values from 0 to that same index in a second array?
Given a numpy array a=[3,5,7] 给定一个numpy数组a = [3,5,7]
How can I efficiently generate a second array b, where b[i] = numpy.Sum(a[0:i]? 如何有效地生成第二个数组b,其中b [i] = numpy.Sum(a [0:i]?
I've looked through the numpy docs but the solution isn't jumping out at me... 我已经查看了numpy文档,但是解决方案并没有对我跳出来...
The expected output would be b=[3,8,15] 预期输出为b = [3,8,15]
Any ideas will be gratefully received!!! 任何想法将不胜感激!!!
Thanks, 谢谢,
Doug 道格
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.