Pandas documentation lists a bunch of "expanding window functions" :
http://pandas.pydata.org/pandas-docs/version/0.17.0/api.html#standard-expanding-window-functions
But I couldn't figure out what they do from the documentation.
Pandas documentation lists a bunch of "expanding window functions" :
http://pandas.pydata.org/pandas-docs/version/0.17.0/api.html#standard-expanding-window-functions
But I couldn't figure out what they do from the documentation.
To sum up the difference between rolling and expanding function in one line: In rolling function the window size remain constant whereas in the expanding function it changes.
Example: Suppose you want to predict the weather, you have 100 days of data:
Rolling: let's say window size is 10. For first prediction, it will use (the previous) 10 days of data and predict day 11. For next prediction, it will use the 2nd day (data point) to 11th day of data.
Expanding: For first prediction it will use 10 days of data. However, for second prediction it will use 10 + 1 days of data. The window has therefore "expanded."
Code example:
sums = series.expanding(min_periods=2).sum()
series contains data of number of previously downloaded apps over time series.
Above written code line sum all the number of downloaded apps till that time.
Note: min_periods=2 means that we need at least 2 previous data points to aggregate over. Our aggregate here is the sum.
Those illustrations from Uber explain the concepts very well:
Sliding window
Original article: https://eng.uber.com/omphalos/