Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python moving average of list

import numpy
def running_mean(x, N):
  """ x == an array of data. N == number of samples per average """
    cumsum = numpy.cumsum(numpy.insert(x, 0, 0)) 
    return (cumsum[N:] - cumsum[:-N]) / float(N)
  
val = [-30.45, -2.65, 56.61, 47.13, 47.95, 30.45, 2.65, -28.31, -47.13, -95.89]
print(running_mean(val, 3))
""" [  7.83666667  33.69666667  50.56333333  41.84333333  27.01666667
   1.59666667 -24.26333333 -57.11      ]	"""
Comment

PREVIOUS NEXT
Code Example
Python :: crear matriz python for 
Python :: list map lambda python 
Python :: how to open cmd at specific location usng python 
Python :: python plot bins not lining up with axis 
Python :: Solving environment: failed with initial frozen solve. retrying with flexible solve 
Python :: getpass 
Python :: python mouse click 
Python :: square finder python 
Python :: python extract name out of mail 
Python :: remove item from list while looping 
Python :: pip install contractions 
Python :: python pandas csv to xlsx semicolon 
Python :: django import settings 
Python :: hoe maak je machten in python 
Python :: make a message appear after specified Time python 
Python :: gmpy2 is prime 
Python :: draw pixel by pixel python 
Python :: plotly express lineplot 
Python :: start the environment 
Python :: how to flip a list backwards in python 
Python :: python nextcord bot slash command 
Python :: numpy get specified colums 
Python :: how to make a clicker game in python 
Python :: filter blank rows python csv 
Python :: train test split pandas 
Python :: replace the jinja template value inside the dictionary python 
Python :: dataframe how to substruct 2 dates 
Python :: default style matplotlib python 
Python :: matplotlib pie label size 
Python :: grouping products for sales 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =