Python Forum
Reduced Moving Averages for time series Data
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reduced Moving Averages for time series Data
#1
I am doing my analysis on time series data using Python. I am also interested in moving averages, to calculate moving averages for my target variable, I used the following function to calculate MA over my target variable.

def movingaverage(values, avg_number):
    weights = np.repeat(1.0, avg_number)/avg_number
    smas = np.convolve(values, weights, 'valid')
    return smas
In this function, I supply my pandas Series and the average number to calc. corresponding averages.

Now, I want to calculate reduced moving averages. like in the above the averages are being calculated over fixed number, say 90.

But, in case of reduced moving averages, this number will reduce by 1 at each next value. Such as I supplied 90 as the average number, my first MA will average of 90 days, my next calculation will be the average of 89 days and so on.

How can I do this using numpy library in Python?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help: Conversion of Electricity Data into Time Series Data SmallGuy 3 1,158 Oct-04-2023, 03:31 PM
Last Post: deanhystad
  Time Series Production Process Problem Mzarour 1 2,100 Feb-28-2023, 12:25 PM
Last Post: get2sid
  reduce time series based on sum condition amdi40 0 1,079 Apr-06-2022, 09:09 AM
Last Post: amdi40
  How to accumulate volume of time series amdi40 3 2,260 Feb-15-2022, 02:23 PM
Last Post: amdi40
  Recommendations for ML libraries for time-series forecast AndreasPython 0 1,862 Jan-06-2021, 01:03 PM
Last Post: AndreasPython
  Find two extremum in data series Sancho_Pansa 0 1,674 Dec-04-2020, 02:06 PM
Last Post: Sancho_Pansa
  Time Series forecating with multiple independent variables Krychol88 1 1,823 Oct-23-2020, 08:11 AM
Last Post: DPaul
  how to handling time series data file with Python? aupres 4 2,925 Aug-10-2020, 12:40 PM
Last Post: MattKahn13
  Changing Time Series from Start to End of Month illmattic 0 1,827 Jul-16-2020, 10:49 AM
Last Post: illmattic
  HELP- DATA FRAME INTO TIME SERIES- BASIC bntayfur 0 1,733 Jul-11-2020, 09:04 PM
Last Post: bntayfur

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020