Questions tagged [cumsum]

Cumsum is a MatLab, NumPy, Pandas and R function that returns the cumulative sum along different dimensions of an array.

Cumsum is a MatLab, NumPy, Pandas and R function that returns the cumulative sum along different dimensions of an array.

799 questions
-3
votes
1 answer

python pandas: group time series by cumsum defined value, reset sum if value is reached

I have a data frame with column A and B. Desired outcome: If cumsum of B reaches value >=15, following operations for the rows between 0 and cumsum >=15 shall be computed: df["Amean"] =df["A"].mean() and df["Bsum15"] = df["B"].sum() ; then cumsum…
mqx
  • 11
  • 4
-4
votes
2 answers

What is the R code for getting the custom sequence of the numbers using cumulative sum?

Input Output 1001 1001 1067 1067 1068 1067 1080 1080 1081 1080 1082 1080 1255 1255 1256 1255 1257 1255 1258 1255 1259 1255 1386 1386 1822 1822 My input column is on the left in my data frame.I need my output…
-4
votes
1 answer

Find a cumulative sum of one column until a conditional sum on another column is met

I would like to find the preceding cumsum (i.e. cumsum minus the present row) for those rows of column B until the sum of the previous rows of column A including present row is <= 7. I was able to find an answer using a traditional for loop. A…
sharp
  • 61
  • 8
-5
votes
1 answer

how to get a cumulative sum on a large dataframe in r

I have a large data dataframe (48 x 100). Is there an elegant formula in R that makes you transform this dataframe in to a "custom dataframe"? a = c(2, 3, 5) b = c(2, 3, 5) c = c(2, 3, 5) df <- rbind(a,b,c) Now.. i want cumsum of df so it looks…
1 2 3
53
54