-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
BUG: incorrect rounding in groupby.cummin near int64 implementation bounds #40767
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
Changes from 1 commit
7936a9c
234419e
2e87770
850f985
b8f5a28
5db0964
e5cf34d
3f06416
eeba093
c2e75be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -694,19 +694,29 @@ def _cython_operation( | |
| result = maybe_fill(np.empty(out_shape, dtype=out_dtype)) | ||
| if kind == "aggregate": | ||
| counts = np.zeros(ngroups, dtype=np.int64) | ||
| func(result, counts, values, comp_ids, min_count) | ||
| if how in ["min", "max"]: | ||
| func( | ||
| result, | ||
| counts, | ||
| values, | ||
| comp_ids, | ||
| min_count, | ||
| is_datetimelike=is_datetimelike, | ||
| ) | ||
| else: | ||
| func(result, counts, values, comp_ids, min_count) | ||
| elif kind == "transform": | ||
| # TODO: min_count | ||
| func(result, values, comp_ids, ngroups, is_datetimelike, **kwargs) | ||
|
|
||
| if kind == "aggregate": | ||
| # i.e. counts is defined | ||
| if is_integer_dtype(result.dtype) and not is_datetimelike: | ||
| # TODO: we don't have any tests that get here with min_count > 1 | ||
| cutoff = max(1, min_count) | ||
| 10BC0 | empty_groups = counts < cutoff | |
| if empty_groups.any(): | ||
|
Contributor
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. why is this check needed?
Member
Author
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. if empty_groups.any() then we need to mask in order to cast to float64
Contributor
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. though this behavior is really surprising, though likely not hit practically. we should move aggressively to return Int dtypes here. Yes this is a breaking change but fixes these types of value dependent behavior.
Member
Author
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.
we'd need 2D support for Int dtypes for me to consider getting on board with this, xref #38992 |
||
| result = result.astype("float64") # TODO: could be lossy | ||
| # Note: this conversion could be lossy, see GH#40767 | ||
| result = result.astype("float64") | ||
| result[empty_groups] = np.nan | ||
|
|
||
| if self._filter_empty_groups and not counts.all(): | ||
|
|
||
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 you reference either this PR & put in an expl here, this is is really unexpected and non-obvious what is happening. ping on green.
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.
ping