-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Raise ValueError for unsupported Window functions #27275
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
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.
this seems like overkill
when you create a Window it already has restricted methods
what error message does this have now (before this PRA)?
@jreback it is ok when directly calling an unsupported function but raised error ( |
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.
looks good, question about if we are correctly raising a ValueError in the list-like case (which you are catching).
Please don't merge this as it raises |
AttributeError is raised since it is conflicting with the one when list-like arg is provided. TypeError is catched since it is raised when 'median' is passed as an arg
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.
lgtm ex any @jreback comments and any CI failures
|
pandas/core/base.py
Outdated
return f(self, *args, **kwargs) | ||
|
||
except (AttributeError, TypeError): | ||
raise AttributeError( |
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 would pass here, then just use a single raise (line 326)
pandas/core/window.py
Outdated
@@ -511,6 +511,7 @@ class Window(_Window): | |||
Set the labels at the center of the window. | |||
win_type : str, default None | |||
Provide a window type. If ``None``, all points are evenly weighted. | |||
Other types are only applicable for `mean` and `sum` functions. |
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.
this should be on .agg so I wouldn't add anything here
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.
agg
is using shared_docs
. I was avoiding to copy it and make a single line change. Will remove it only if no objection
lgtm @ihsansecer ping on green. |
thanks @ihsansecer |
btw now that pandas/tests/window/ exists would love to split test_window even more :-> |
@jreback noted :) |
git diff upstream/master -u -- "*.py" | flake8 --diff
Weighted std could be implemented but there are also other functions weighted
Window
is lacking.