pydata/pandas — pull request #1785 by qwhelan (2012-08-20 00:03:45+00:00)
Title: Add expanding moment functions and related tests.

Implement `expanding_` analogues to the `rolling_` moment functions available in `pandas/stats/moments.py` by calling the `rolling_` function with `window=len(arg)` and `min_periods` defaulting to the minimum number of data points to compute the statistic (`1` for most, `4` for kurtosis, etc.). Resolves Issue #849.

The only potentially surprising behavior is that some `expanding_` functions differ from their NumPy equivalents in whether they preserve `NaN`s. For example, `expanding_max(s)` is equivalent to `rolling_max(s, len(s), min_periods=1)`, but both produce different output from `s.cummax()`, as the latter always returns `NaN` for every `NaN` in `s`. I don't have a strong opinion on which output is correct, aside from thinking `rolling_` and `expanding_` should agree.