Moving average

The moving average is a forecasting and smoothing method that computes the average of the last n observed values. It dampens noise but reacts with a lag to trend changes. A small window follows variations quickly, a large window smooths more.

Example

df['prev'] = df['ventes'].rolling(3).mean().shift(1)

Related concepts

The whole glossary