-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: preempt TypeError for EAs in groupby agg_series #29186
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 all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ca136de
BUG: IndexError in libreduction
jbrockmendel 14e2433
BUG: fix TypeError raised in maybe_downcast_numeric
jbrockmendel 37d829b
BUG: fix AttributeError raised in libreduction
jbrockmendel ec9e851
missed one
jbrockmendel ce2b9ba
revert re-raising AttributeError
jbrockmendel 030e6fb
Add a regression test for the timezone issue (#29097)
grigoriosgiann 618462f
Fix typing errors (#29115)
AbhijeetKrishnan 762d0bc
Fix typing errors (#29114)
AbhijeetKrishnan f06432e
Fix mypy errors (#29108)
AbhijeetKrishnan 6242ddc
fix #28926 mypy error in pandas\tests\arrays\test_array.py (#28970)
yogendrasoni 3602bd6
Merge branch 'master' of https://github.com/pandas-dev/pandas into fa…
jbrockmendel fdf5f1c
Merge branch 'master' of https://github.com/pandas-dev/pandas into fa…
jbrockmendel 085bd40
Merge branch 'master' of https://github.com/pandas-dev/pandas into fa…
jbrockmendel 18fc0e9
Merge branch 'master' of https://github.com/pandas-dev/pandas into fa…
jbrockmendel 0042cdf
port decimal test
jbrockmendel f48c9ff
Merge branch 'master' of https://github.com/pandas-dev/pandas into fa…
jbrockmendel 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
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -26,6 +26,7 @@ | |||||||||||||||
is_complex_dtype, | ||||||||||||||||
is_datetime64_any_dtype, | ||||||||||||||||
is_datetime64tz_dtype, | ||||||||||||||||
is_extension_array_dtype, | ||||||||||||||||
is_integer_dtype, | ||||||||||||||||
is_numeric_dtype, | ||||||||||||||||
is_sparse, | ||||||||||||||||
|
@@ -659,6 +660,12 @@ def _transform( | |||||||||||||||
return result | ||||||||||||||||
|
||||||||||||||||
def agg_series(self, obj, func): | ||||||||||||||||
if is_extension_array_dtype(obj.dtype) and obj.dtype.kind != "M": | ||||||||||||||||
# _aggregate_series_fast would raise TypeError when | ||||||||||||||||
# calling libreduction.Slider | ||||||||||||||||
# TODO: is the datetime64tz case supposed to go through here? | ||||||||||||||||
return self._aggregate_series_pure_python(obj, func) | ||||||||||||||||
|
||||||||||||||||
try: | ||||||||||||||||
return self._aggregate_series_fast(obj, func) | ||||||||||||||||
except AssertionError: | ||||||||||||||||
|
@@ -683,6 +690,8 @@ def agg_series(self, obj, func): | |||||||||||||||
def _aggregate_series_fast(self, obj, func): | ||||||||||||||||
func = self._is_builtin_func(func) | ||||||||||||||||
|
||||||||||||||||
# TODO: pre-empt this, also pre-empt get_result raising TypError if we pass a EA | ||||||||||||||||
# for EAs backed by ndarray we may have a performant workaround | ||||||||||||||||
if obj.index._has_complex_internals: | ||||||||||||||||
raise TypeError("Incompatible index for Cython grouper") | ||||||||||||||||
|
||||||||||||||||
|
@@ -717,6 +726,7 @@ def _aggregate_series_pure_python(self, obj, func): | |||||||||||||||
result[label] = res | ||||||||||||||||
|
||||||||||||||||
result = lib.maybe_convert_objects(result, try_float=0) | ||||||||||||||||
# TODO: try_cast back to EA? | ||||||||||||||||
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 done in the code calling this (via pandas/pandas/core/groupby/groupby.py Lines 899 to 905 in 82df98a
|
||||||||||||||||
return result, counts | ||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
|
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.
Do you know why it is working for datetimes?