Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ENH: Implement __iter__ for Rolling and Expanding #34201
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
ENH: Implement __iter__ for Rolling and Expanding #34201
Changes from 15 commits
7e461a1
1314059
8bcb313
24c3ede
dea38f2
cd9e7ac
e5e912b
045a76f
7e6779f
4d85ab9
fe74bc9
c0f4cf4
3bb2cf0
ac23518
7f74b79
5577efc
fd6e9a9
3cefb23
1623593
61af135
7e85f87
9b84e74
8379810
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO since
min_periods
is supposed to influence the the aggregation result, and we're just returning the window here, I think we should always return the result and not filter results based oniter_threshold
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emm, i am not sure about this actually, because
df.rolling(window=2, min_periods=3).sum()
for instance is not allowed, and will raise aValueError
because min_periods has to be equal or smaller than window in aggregation, that is why i think maybe it makes a bit more sense to have the minimum here betweenwindow
andmin_periods
.but I also do not know if this matters in
iter
? maybe raise an error here, does it sound more reasonable?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right I am thinking it doesn't matter in
__iter__
because the aggregation hasn't happened yet (sum
), and it's up to the user to decide what they want to do with each window.From the user perspective, I can see a potential source of confusion if not all the windows are returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, leaving it to users sounds more convincing!
thanks, @mroeschke ! i have updated the PR to remove this check (also no error raising) here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks! Might want to document this behavior in
computation.rst
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, added! thanks for the reviews! @mroeschke