-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
Breaking changes for sum / prod of empty / all-NA #18921
Merged
TomAugspurger
merged 14 commits into
pandas-dev:master
from
TomAugspurger:sum-mincount-breaking
Dec 29, 2017
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
790330d
API: Change the sum of all-NA / all-Empty sum / prod
TomAugspurger 541a362
Max, not min
TomAugspurger a267c2f
Update whatsnew
TomAugspurger 8c06739
Parametrize test
TomAugspurger df7c69a
Minor cleanups
TomAugspurger 66a3ab6
Refactor skipna_alternative
TomAugspurger fb5937c
Split test
TomAugspurger 4c65c9c
Added issue
TomAugspurger 52e4e6f
More updates
TomAugspurger d6a6c22
linting
TomAugspurger fcd57f4
linting
TomAugspurger 05b44f9
Added skips
TomAugspurger cdf5692
Doc fixup
TomAugspurger a97e133
DOC: More whatsnew
TomAugspurger 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 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 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 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 |
---|---|---|
|
@@ -220,14 +220,16 @@ cdef class VariableWindowIndexer(WindowIndexer): | |
right_closed: bint | ||
right endpoint closedness | ||
True if the right endpoint is closed, False if open | ||
|
||
floor: optional | ||
unit for flooring the unit | ||
""" | ||
def __init__(self, ndarray input, int64_t win, int64_t minp, | ||
bint left_closed, bint right_closed, ndarray index): | ||
bint left_closed, bint right_closed, ndarray index, | ||
object floor=None): | ||
|
||
self.is_variable = 1 | ||
self.N = len(index) | ||
self.minp = _check_minp(win, minp, self.N) | ||
self.minp = _check_minp(win, minp, self.N, floor=floor) | ||
|
||
self.start = np.empty(self.N, dtype='int64') | ||
self.start.fill(-1) | ||
|
@@ -342,7 +344,7 @@ def get_window_indexer(input, win, minp, index, closed, | |
|
||
if index is not None: | ||
indexer = VariableWindowIndexer(input, win, minp, left_closed, | ||
right_closed, index) | ||
right_closed, index, floor) | ||
elif use_mock: | ||
indexer = MockFixedWindowIndexer(input, win, minp, left_closed, | ||
right_closed, index, floor) | ||
|
@@ -441,15 +443,16 @@ def roll_sum(ndarray[double_t] input, int64_t win, int64_t minp, | |
object index, object closed): | ||
cdef: | ||
double val, prev_x, sum_x = 0 | ||
int64_t s, e | ||
int64_t s, e, range_endpoint | ||
int64_t nobs = 0, i, j, N | ||
bint is_variable | ||
ndarray[int64_t] start, end | ||
ndarray[double_t] output | ||
|
||
start, end, N, win, minp, is_variable = get_window_indexer(input, win, | ||
minp, index, | ||
closed) | ||
closed, | ||
floor=0) | ||
output = np.empty(N, dtype=float) | ||
|
||
# for performance we are going to iterate | ||
|
@@ -489,13 +492,15 @@ def roll_sum(ndarray[double_t] input, int64_t win, int64_t minp, | |
|
||
# fixed window | ||
|
||
range_endpoint = int_max(minp, 1) - 1 | ||
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. nice! |
||
|
||
with nogil: | ||
|
||
for i in range(0, minp - 1): | ||
for i in range(0, range_endpoint): | ||
add_sum(input[i], &nobs, &sum_x) | ||
output[i] = NaN | ||
|
||
for i in range(minp - 1, N): | ||
for i in range(range_endpoint, N): | ||
val = input[i] | ||
add_sum(val, &nobs, &sum_x) | ||
|
||
|
This file contains 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 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
Oops, something went wrong.
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.
say matches numpy? (I know you are saying
np.nansum
, but can't hurt to actually say numpy)