Skip to content
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

ERR: better error message with .rolling().apply(func using non-numpy things, raw=True) #38809

Open
jreback opened this issue Dec 30, 2020 · 5 comments
Labels
Enhancement Error Reporting Incorrect or improved errors from pandas Window rolling, ewma, expanding

Comments

@jreback
Copy link
Contributor

jreback commented Dec 30, 2020

we could use a better error message rather than AttributeError e.g. #38804 (comment)

when using

df.rolling(...).apply(f, raw=True)

when f is using non-numpy functions e.g. .iloc

@jreback jreback added Error Reporting Incorrect or improved errors from pandas Window rolling, ewma, expanding labels Dec 30, 2020
@jreback jreback added this to the Contributions Welcome milestone Dec 30, 2020
@jorisvandenbossche
Copy link
Member

Why would we want another error message? The user is passing a User Defined Function, and an error happens inside that function. In which case we should show that error to the user?

@jreback
Copy link
Contributor Author

jreback commented Dec 30, 2020

not saying we would want a different error message rather have more context / helpful pointer about this

@mroeschke
Copy link
Member

So when raw is specifically True, we would want to raise something like

try:
    ...
except Exception as e:
    if raw:
        raise ValueError("Applied function failed. Please ensure the passed function does not call any pandas methods or attribues) from e

?

@mroeschke
Copy link
Member

I may be leaning more just clarifying this in the documentation as the error message from the linked reference is fairly clear.

@jreback
Copy link
Contributor Author

jreback commented Dec 30, 2020

idk, the error message you add above is pretty indicative and useful.

@mroeschke mroeschke removed this from the Contributions Welcome milestone Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Error Reporting Incorrect or improved errors from pandas Window rolling, ewma, expanding
Projects
None yet
Development

No branches or pull requests

3 participants