Questions tagged [rolling-average]

104 questions
2
votes
2 answers

Rolling max excluding current observation in Pandas 1.0

Using Pandas 1.0 I need to generate a rolling max with a window of the previous 3 observations, excluding the current observation. In R this is achieved by library(tidyverse) test_df = data.frame(a = 1:5, b = c(40, 37, 60, 45, 40)) ​ test_df <-…
Javide
  • 2,477
  • 5
  • 45
  • 61
1
vote
0 answers

7 Day Rolling Average

insert into job_data(ds,job_id,actor_id,event,language,time_spent,org) values ('2020-11-30',21,1001,'skip','English',15,'A'), ('2020-11-30',22,1006,'transfer','Arabic',25,'B'), …
Ritvik81
  • 11
  • 3
1
vote
1 answer

Exclude center value from centered rolling average in Pandas

I want to calculate the centered rolling average in Pandas, where the center value is excluded. The code below works perfectly, but it includes the center value: df.Value.rolling(window=11, center=True, min_periods=1).mean() The window=11 and…
Crowford99
  • 13
  • 4
1
vote
1 answer

How to calculate three year rolling return using R

I need to get a 3-year rolling return working (3-year return for each id, for each year). I have tried to use the PerformanceAnalytics package but I keep getting an error that my data is not a time series. When I use the function it says TRUE so I…
1
vote
1 answer

How to make an average of every n previous values in R and only if is above zero (excluding "x" value)

I have this matrix: matrix = value1 value2 value3 value4 value5 value6 value7 value8 value9 value10 1 0 0 45 6 6 8 3 0 4 5 2 0 0 0 2 9 1 8 3 0 0 n n n n n n n n n n n what i want: roll_aver…
willxwil
  • 13
  • 3
1
vote
2 answers

Find Rolling Average of Last 6 values in a row

I have data in googlesheet that I need to find the average of the last 6 values in a row. Every week I add another data point so I would need it to calculate the rolling average. I tried using the following formula to calculate…
1
vote
1 answer

Calculating Moving Average of a column based on values of another column in a dataframe Python (Pandas)

I am trying to create a column of the 10-day moving average of points for nba players. My dataframe has game by game statistics for each player, and I would like to have the moving average column contain the 10 day moving average at that point. I…
1
vote
2 answers

Performing a rolling average with criteria in R

Been trying to learn the most basic of items at first and then expanding the complexity. So for this one, how would I modify the last line to where it would be create a rolling 12 month average for each seriescode. In this case, it would produce an…
Tim Wilcox
  • 1,275
  • 2
  • 19
  • 43
1
vote
1 answer

dynamic rolling average in sql

Hope I can explain this properly I'm trying to calculate a rolling average, but with a variable number of preceding rows, depending on a rolling sum of another column. Or in other words, I want to calculate the recent average of column b, over…
Angus
  • 41
  • 5
1
vote
2 answers

Create rolling average in dataframe until a set point

I have a dataframe like this: month val1 val2 val3 1 2 3 5 2 3 4 7 3 5 1 2 4 7 4 3 5 2 6 4 6 2 2 2 The last month in my initial column is 6 here, but could be anything from month 1…
Arlowest
  • 55
  • 5
1
vote
1 answer

Rolling Average in sqlite

I want to calculate a rolling average in a table and keep track of the starting time of each calculated window frame. My problem is, that I expect result count reduced compared of the rows in the table. But my query retuns the exact same row…
ChristianMurschall
  • 1,621
  • 15
  • 26
1
vote
4 answers

Using Rolling Average to Calculate over Window of Values

I am trying to calculate rolling averages of Heart Rate over 15 second intervals. I have millisecond data for many participants and as such the millisecond values can potentially be repeated multiple times, and due to inconsistent time readings,…
KNichs
  • 13
  • 4
1
vote
1 answer

Calculate Average of last n number of weeks in Power BI

I have data in which a row haa number of week and the corresponding sales on this week. Now for each week i want to calculate the average sales of last 8 weeks using DAX formula.
unaseer
  • 119
  • 2
  • 12
1
vote
1 answer

Rolling Average in Pandas

I have a dataframe with 2 columns - Date and Price. The data is sorted with newest date first (23 Jan in first row, 22 Jan in second row and so on). Date Price 23 Jan 100 22 Jan 95 21 Jan 90 . . . I want to calculate 2 days rolling average price…
Manish Jain
  • 13
  • 1
  • 3
1
vote
1 answer

Pandas rolling apply skip certain values

I have a dataframe and I want to calculate the mean column up til the value points I have for True valid cases. ids valid value mean (target output) 1 False 0.1 0 1 True …
Matt-pow
  • 946
  • 4
  • 18
  • 31