I've got a distribution of numbers in an array called predictions and I wanted a moving average. I am new to Python, so I've not used numpy here, just ordinary arrays. My question is there a more graceful way of doing this?
Here is the code:
predictions = []  #Already filled with 7001 values
movingaverage = []
pmean = []
n=-1
count = 0
sumpm = 0
for z in range(40000):
    n+=1
    count+=1
    pmean.append(predictions[n])
    if(count == 5):
        for j in range(5):
            sumpm+=pmean[j]
        sumpm=sumpm/5
        movingaverage.append(sumpm)
        n=n-5
        pmean = []
        sumpm=0
        count = -1
The size of predictions array is 7001 or can use len(predictions).
 
     
    