Questions tagged [rolling-sum]

75 questions
0
votes
1 answer

calculate on pandas rolling windows data

I have some problems with data processing based on a pandas rolling-window using a simple self-built function. I have three columns with values and want to use a simple list comprehension to compute one column out of it for further processing. In my…
osteocyt
  • 47
  • 6
0
votes
0 answers

Get original values from rolling sum

Let's assume I have a very long list of non-negative numbers (X1, X2, ...), but I don't know the values in the list. What I do know is the rolling sums of the elements (let's say: the sum of all 5 consecutive elements in the original list) Thus, we…
babo
  • 1
0
votes
2 answers

Calculating a rolling division in r data table

I have a data table like this: a group 1: 1 a 2: 2 a 3: 3 a 4: 4 a 5: 5 a 6: 6 a The sample can be created from the code below: structure(list(a = 1:100, group = c("a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a",…
ira
  • 2,542
  • 2
  • 22
  • 36
0
votes
2 answers

Calculating sum of array elements and reiterate for entire array in MATLAB

I have a vector A of size 7812x1 and would like to calculate the sum of fixed windows of length 21 (so 372 blocks). This should be reiterated, so that the output should return a vector of size 372x1. I have t=7812, p=372, w=21; for t=1:p out =…
Joe
  • 457
  • 5
  • 18
0
votes
1 answer

Python pandas rolling.apply two time-series input into function

I have a DatetimeIndex indexed dataframe with two columns. The index is uneven. A B Date 2016-01-04 1 20 2016-01-12 2 10 2016-01-21 3 10 2016-01-25 2 20 2016-02-08 2 30 2016-02-15 1 20 2016-02-21 3 …
Laura
  • 360
  • 2
  • 15
0
votes
1 answer

R: Rolling sum on a non standard window

I have an irregular time series, and i'm trying to account with R a rolling sum on 3 month window for each operation associated to an ID. data are structured as follow ID Operation date value A 1 01/01/2017 0 A …
Tyu1990
  • 147
  • 1
  • 1
  • 6
0
votes
0 answers

Fastest way to do a rolling sum in R

There have been several inquiries about doing rolling sums in R, but none have fully addressed the complexity of the problem. I am curious about finding the fastest way to take a rolling sum on a dataset with the following characteristics: • At…
Josh
  • 1
  • 2
0
votes
1 answer

Conditional Rolling Sum (rolling average) in R

ID Year Firm Score 1 2005 A 2 1 2006 A 5 1 2006 B 1 1 2007 A 36 1 2007 E 69 1 2008 E 8 1 2008 B 54 1 2009 A 25 1 2009 C 2 1 2010 E 2 1 2010 B 2 1 2011 A 5 1 …
SriM
  • 11
  • 4
0
votes
2 answers

SQL sum 12 weeks of data based on first sold date across different items

The database has thousands of individual items, each with multiple first sold dates and sales results by week. I need a total sum for each products first 12 weeks of sales. Code was used for previous individual queries when we know the start date…
Kirsty MH
  • 11
  • 2
0
votes
3 answers

Functional Programming way to calculate something like a rolling sum

Let's say I have a list of numerics: val list = List(4,12,3,6,9) For every element in the list, I need to find the rolling sum, i,e. the final output should be: List(4, 16, 19, 25, 34) Is there any transformation that allows us to take as input…
Ankit Khettry
  • 997
  • 1
  • 13
  • 33
0
votes
1 answer

Rolling cumulative sum on MySQL query

I have for example the following table : date sales 2016-02-01 2 2016-02-02 4 2016-02-03 4 2016-02-04 7 2016-02-05 3 2016-02-06 1 2016-02-07 6 2016-02-08 3 I would like to obtain a column that makes a…
Fredovsky
  • 387
  • 4
  • 16
-1
votes
2 answers

Do a rolling sum of a columns using python

I need to do a rolling sum of a columns of a dataframe, verify if the sum of the rolling (2 to 5 lines) is = 0 and take all the lines from the rolling to flag them as "canceled". I tried this : df_sorted = df.sort_values('No Piece FI') df_sorted['No…
Teddy
  • 143
  • 8
-1
votes
1 answer

Month-until-date rolling calculation in BigQuery

Can anyone help with calculating sales figures for month-until-date rolling sum on a data table carrying Datetime column and Sales figures column? Using OVER in standard sql can help me calculate rows/dates preceding the current row, but I am having…
-1
votes
2 answers

SUM in SQL Server with PARTITION BY clause

I have the following table QuotationId QuotationDetailId DriverId RangeFrom RangeTo FixedAmount UnitAmount ------------------------------------------------------------------------------------------- 10579 7 1 …
user2332607
  • 99
  • 1
  • 3
  • 10
-2
votes
1 answer

Rolling Sum SQL Server pre-2012

I have a question regarding the rolling sum in SQL Server Pre-2012. as you can see from the text below, I have a serious of money flows on a monthly basis and I would like to calculate the rolling sum in order to achieve different time horizon (e.g.…
Steven Ingo
  • 19
  • 1
  • 5
1 2 3 4
5