python - Perform a reverse cumulative sum on a numpy array -
can recommend way reverse cumulative sum on numpy array?
where 'reverse cumulative sum' defined below (i welcome corrections on name procedure):
if
x = np.array([0,1,2,3,4])
then
np.cumsum(x)
gives
array([0,1,3,6,10])
however, get
array([10,10,9,7,4]
can suggest way this?
this it:
np.cumsum(x[::-1])[::-1]
Comments
Post a Comment