Skip to content

CLN: Don't intercept NotImplementedError in _cython_transform #49742

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 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1362,8 +1362,9 @@ def arr_func(bvalues: ArrayLike) -> ArrayLike:
arr_func, ignore_failures=numeric_only is lib.no_default
)
except NotImplementedError as err:
# For NotImplementedError, args[0] is the error message
raise TypeError(err.args[0]) from err
# For NotImplementedError, args[0] is the error message when available
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im fine with this, but FWIW id just not catch this and let the NotImplementedError bubble up

Copy link
Member Author

@rhshadrach rhshadrach Nov 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good - I'll take that approach here. The only functions in our test that currently raise here are cumsum, cummin, cummax, and cumprod. I'm thinking longer term it'd be better to provide a Python fallback for object dtypes where cumsum (on strings, at least), cummin, and cummax could be successful, and cumprod will then raise the proper TypeError. Does that make sense?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems reasonable

msg = err.args[0] if len(err.args) > 0 else ""
raise TypeError(msg) from err
res_mgr.set_axis(1, mgr.axes[1])

if len(res_mgr) < orig_mgr_len:
Expand Down