import numpy as np

a = np.array([[0, 1, 2, 3],
             [4, 5, 6, 7],
             [8, 9, 10, 11]])

print(np.cumsum(a)) # 1 次元 array に変換してから累積和を計算

'''
[ 0  1  3  6 10 15 21 28 36 45 55 66]
'''

print(np.cumsum(a, axis=0)) # 縦方向に累積和を計算

'''
[[ 0  1  2  3]
 [ 4  6  8 10]
 [12 15 18 21]]
'''

print(np.cumsum(a, axis=1)) # 横方向に累積和を計算

'''
[[ 0  1  3  6]
 [ 4  9 15 22]
 [ 8 17 27 38]]
'''
