-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: don't catch AttributeError in _wrap_applied_output #29195
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
Conversation
@@ -198,6 +198,9 @@ def apply(self, f, data, axis=0): | |||
f_name not in base.plotting_methods | |||
and hasattr(splitter, "fast_apply") | |||
and axis == 0 | |||
# with MultiIndex, apply_frame_axis0 would raise InvalidApply | |||
# TODO: can we make this check prettier? | |||
and not splitter._get_sorted_data().index._has_complex_internals |
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 generally know of a reason why we have _has_complex_internals
as a Index property? I think only changed for a MultiIndex and only applicable in groupby space.
Might be easier and clearer to just do a isinstance(..., MultiIndex)
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.
I'm not aware of the history there no.
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.
Cool; just asking - probably a historical relic.
Haven't gone too deep on this one yet but will file comments (most likely) tomorrow
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.
_has_complex_internals predates me :->
stacked_values = np.vstack([np.asarray(v) for v in values]) | ||
result = DataFrame( | ||
stacked_values.T, index=v.index, columns=key_index | ||
) | ||
else: | ||
# GH#1738: values is list of arrays of unequal lengths |
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.
a better way to do this would be to make this if/elif into a function, then just return on the if/elif; that way you can avoid suplicating 1279 and 1287
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.
generally agree, but I think the version on 1287 doesnt need to be there at all (not reached in tests). Just not removing it until im sure
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.
ok, then merge this and followup?
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.
yes please. got a couple of local branches about ready to go
Thanks @jbrockmendel |
cc @jreback @WillAyd