WeCodeAcademy

Rolling Averages and Running Totals

Time series data is noisy. A rolling average replaces each value with the average of the last few, smoothing the jumps: .rolling(3).mean(). The first values are NaN because there is not enough history yet. .cumsum() gives a running total and .pct_change() the percentage change from the previous row.

Examplepython
Open in editor »
Quick check

Why are the first values of `rolling(3).mean()` NaN?

Your turn: write the code

Print the running total of the series.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.