Moving Average

Easy
pandas

Given a list of numbers, compute the simple moving average with a window size of k. Return the result as a list of floats.

For positions where the full window is not available, return None.

Example:

Input:  values = [1, 2, 3, 4, 5], k = 3
Output: [None, None, 2.0, 3.0, 4.0]

Test Cases

Python Editor

Output

Click "Run" to see results...