moving-average

Calculating a rolling weighted sum using numpy

Calculating a rolling weighted sum using numpy Question: I am curious to know if there are any more optimal ways to compute this "rolling weighted sum" (unsure what the actual terminology is, but I will provide an example to further clarify). I am asking this because I am certain that my current code snippet is …

Total answers: 2

Is there a way to get Pandas ewm to function on fixed windows?

Is there a way to get Pandas ewm to function on fixed windows? Question: I am trying to use Pandas ewm function to calculating exponentially weighted moving averages. However i’ve noticed that information seems to carry through your entire time series. What this means is that every data point’s MA is dependant on a different …

Total answers: 3

Calculating Rolling forward averages with pandas

Calculating Rolling forward averages with pandas Question: I need to calculate some rolling forward averages in a dataframe and really don’t know where to start. I know if I wanted to select a cell 10 days ahead say I would do df.shift(-10), but what I’m looking to do is calculate the average between 10 and …

Total answers: 4

Python Pandas: Calculate moving average within group

Python Pandas: Calculate moving average within group Question: I have a dataframe containing time series for 100 objects: object period value 1 1 24 1 2 67 … 1 1000 56 2 1 59 2 2 46 … 2 1000 64 3 1 54 … 100 1 451 100 2 153 … 100 1000 21 …

Total answers: 6

Average on overlapping windows in Python

Average on overlapping windows in Python Question: I’m trying to compute a moving average but with a set step size between each average. For example, if I was computing the average of a 4 element window every 2 elements: data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] This should produce the …

Total answers: 3

How to calculate rolling / moving average using python + NumPy / SciPy?

How to calculate rolling / moving average using python + NumPy / SciPy? Question: There seems to be no function that simply calculates the moving average on numpy/scipy, leading to convoluted solutions. My question is two-fold: What’s the easiest way to (correctly) implement a moving average with numpy? Since this seems non-trivial and error prone, …

Total answers: 19

Moving average or running mean

Moving average or running mean Question: Is there a SciPy function or NumPy function or module for Python that calculates the running mean of a 1D array given a specific window? Asked By: Shejo284 || Source Answers: For a ready-to-use solution, see https://scipy-cookbook.readthedocs.io/items/SignalSmooth.html. It provides running average with the flat window type. Note that this …

Total answers: 30