-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: support count function for custom BaseIndexer rolling windows #33605
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
98c7183
enable count for BaseIndexer windows
AlexKirko a812a8f
TST: add count to the test
AlexKirko b540cf0
ENH: actually get custom windows for count
AlexKirko 0c212b8
remove validation from count
AlexKirko 5877141
DOC: add whatsnew entry
AlexKirko af41d6f
DOC: clarify the comment
AlexKirko f8a126a
add self.window class check to count
AlexKirko 12fc3b3
DOC: add comment to assert
AlexKirko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1171,8 +1171,6 @@ class _Rolling_and_Expanding(_Rolling): | |
) | ||
|
||
def count(self): | ||
if isinstance(self.window, BaseIndexer): | ||
validate_baseindexer_support("count") | ||
|
||
blocks, obj = self._create_blocks() | ||
results = [] | ||
|
@@ -1939,7 +1937,9 @@ def aggregate(self, func, *args, **kwargs): | |
def count(self): | ||
|
||
# different impl for freq counting | ||
if self.is_freq_type: | ||
# GH 32865. Also use custom rolling windows calculation | ||
# when using a BaseIndexer subclass | ||
if self.is_freq_type or isinstance(self.window, BaseIndexer): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the crux of the issue. Because we didn't check for |
||
window_func = self._get_roll_func("roll_count") | ||
return self._apply(window_func, center=self.center, name="count") | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Custom
BaseIndexer
implementations should never go into this function. Instead,_get_window_indexer
gets called, and there is avalidate_baseindexer_support
there (checked that it works by temporarily blacklistingcount
again)Removing this check as unnecessary.
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.
can u add an assertion 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.
Done.