Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add expanding moment functions and related tests. #1785

Merged
merged 1 commit into from
Sep 8, 2012

Conversation

qwhelan
Copy link
Contributor

@qwhelan qwhelan commented Aug 20, 2012

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 NaNs. 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.

wesm added a commit that referenced this pull request Sep 8, 2012
@wesm wesm merged commit 30ebd9e into pandas-dev:master Sep 8, 2012
@wesm
Copy link
Member

wesm commented Sep 8, 2012

This is great, thanks. I'd held off on adding the expanding window functions but they're useful to have and will reduce the number of questions I get ;) It would be nice to add something to the documentation about them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants