Skip to content

Glossary: ML Beyond the Basics

Shift, rolling and expanding (pandas history tools)

Also written: expanding().mean(), expanding, rolling, shift, rolling window

pandas tools for features from a customer's own past. `shift(n)` takes the value n rows earlier, `rolling(3).sum()` totals this row and the two before, and `expanding().mean()` averages all rows so far. All look only backward, so they don't leak.

Where the book teaches it

Related terms

Leakage from the futureFeature