I am trying to find a way to calculate an inverse cumsum for pandas. This means applying cumsum
but from bottom to top. The problem I\'m facing is, I\'m trying to f
Whichever column you want to apply cumsum to you have two options:
1. Order descending a copy of that column by index, followed by cumsum and then order ascending by index. Finally assign it back to the data frame column.
import numpy as np
array = df.column_data.to_numpy()
array = np.flip(array) # to flip the order
array = numpy.cumsum(array)
array = numpy.flip(array) # to flip back to original order
df.column_data_cumsum = array