np.cumsum

import numpy as np

a = np.array([[1, 2, 3], [4, 5, 6]])
a = np.array([[1, 2, 3, 4, 5, 6]])
print(np.cumsum(a))

按照所给定的轴参数返回元素的梯形累计和,axis=0,按照行累加。axis=1,按照列累加。axis不给定具体值,就把numpy数组当成一个一维数组。

[ 1  3  6 10 15 21]

http://www.waitingfy.com/archives/5083

5083

Leave a Reply

Name and Email Address are required fields.
Your email will not be published or shared with third parties.