Skip to content

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

Merged
merged 18 commits into from
Jul 11, 2019

Conversation

ihsansecer
Copy link
Contributor

Weighted std could be implemented but there are also other functions weighted Window is lacking.

Copy link
Contributor

@jreback jreback left a 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)?

@ihsansecer
Copy link
Contributor Author

@jreback it is ok when directly calling an unsupported function but raised error (AttributeError: 'Window' object has no attribute 'dtype') is not informative for agg function

@WillAyd WillAyd added the Window rolling, ewma, expanding label Jul 7, 2019
Copy link
Contributor

@jreback jreback left a 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).

@ihsansecer
Copy link
Contributor Author

Please don't merge this as it raises ValueError: no results in some cases. Will check it when I have time

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
Copy link
Member

@WillAyd WillAyd left a 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

@ihsansecer
Copy link
Contributor Author

skew and kurt functions as an argument to agg raises unknown string function error. min and max functions on the other hand doesn't raise anything and returns Windowobject.

return f(self, *args, **kwargs)

except (AttributeError, TypeError):
raise AttributeError(
Copy link
Contributor

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)

@@ -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.
Copy link
Contributor

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

Copy link
Contributor Author

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

@jreback jreback added this to the 0.25.0 milestone Jul 11, 2019
@jreback
Copy link
Contributor

jreback commented Jul 11, 2019

lgtm @ihsansecer ping on green.

@jreback jreback merged commit d3e84b7 into pandas-dev:master Jul 11, 2019
@jreback
Copy link
Contributor

jreback commented Jul 11, 2019

thanks @ihsansecer

@jreback
Copy link
Contributor

jreback commented Jul 11, 2019

btw now that pandas/tests/window/ exists would love to split test_window even more :->

@ihsansecer
Copy link
Contributor Author

@jreback noted :)

@ihsansecer ihsansecer deleted the val-window-agg branch July 11, 2019 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Window rolling, ewma, expanding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants