-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: move small bits outside of try/excepts #28962
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 all commits
4d73f11
a2e55a1
a964366
ea07301
ea65439
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -598,14 +598,7 @@ def pipe(self, func, *args, **kwargs): | |
plot = property(GroupByPlot) | ||
|
||
def _make_wrapper(self, name): | ||
if name not in self._apply_whitelist: | ||
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 cleanup. At a glance this looks like a pretty interesting factory... 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. Yah, this used to be called from within |
||
is_callable = callable(getattr(self._selected_obj, name, None)) | ||
kind = " callable " if is_callable else " " | ||
msg = ( | ||
"Cannot access{0}attribute {1!r} of {2!r} objects, try " | ||
"using the 'apply' method".format(kind, name, type(self).__name__) | ||
) | ||
raise AttributeError(msg) | ||
assert name in self._apply_whitelist | ||
|
||
self._set_group_selection() | ||
|
||
|
@@ -919,9 +912,10 @@ def _python_agg_general(self, func, *args, **kwargs): | |
for name, obj in self._iterate_slices(): | ||
try: | ||
result, counts = self.grouper.agg_series(obj, f) | ||
output[name] = self._try_cast(result, obj, numeric_only=True) | ||
except TypeError: | ||
continue | ||
else: | ||
output[name] = self._try_cast(result, obj, numeric_only=True) | ||
|
||
if len(output) == 0: | ||
return self._python_apply_general(f) | ||
|
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 we need to account for
__array_ufunc__
or__array_function__
here as well? @TomAugspurger might want to take a lookThere 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.
IIUC, this change is OK since we're checking if
self
has__array__
, which our Index / Series objects have (in addition to array_ufunc)