-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Empty product not equal to 1 #7889
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
Comments
hmm, that is different from numpy.... want to do a pull-request? |
xref #7869 If you want to fix this, the problem is in the |
I do not feel comfortable fixing this myself, so I will wait. Thanks for the prompt responses! |
Ooops. Accidentally closed. Now open again I hope. (I am not very experienced with Github.) |
I can take this. |
@anderslundstedt @jreback Fixing this to be consistent with |
I would just fix that test ('prod') as its 'wrong' too |
i did that in the pr |
whoops forgot to xref this issue |
@cpcloud Can you give an example of a resample that would break? Eg, would the
|
Do we care that |
@jorisvandenbossche no, if the group key is
|
@cpcloud Hmm, I don't fully get that. What is the difference? When the third row is set to WIth 0.14.1, your example gives:
So the |
Those will be one as well I just have my display max rows set to 10. I'll post the full example in a bit |
Yes it's a breaking change, I'm not sure if it's the way to go as I'm not sure if this brings any benefits other that consistency with numpy and Wikipedia. OTOH I would've expected more breakage by changing the zero value default in nanops |
So would it in some way be possible to regard this example above as a product of |
@cpcloud It is more than "consistency with Wikipedia", it is matter of consistency with any mathematical identity involving a possibly empty product. |
It was a tongue in cheek comment. I don't like introducing "valid" values where previously there were nans. This seems like it would break a ton of existing code. @anderslundstedt what operations are you doing that allowed you to find this inconsistency? |
Well, I want to take the product of a possibly empty series. The context is that I want to compute historical stock prices adjusted for dividend etc., when there has been no dividend after price time this involves an empty product. |
Can you show some code and data in an example? Thanks. |
I do not see the point and I am not able to share the code I work with. My initial post basically sums up the problem. It is not difficult to work around, so it is not a problem (for me) if you do not change the behaviour. Just though it would be nice with empty products equal to one, but I understand that you may not want to break existing code. |
What I wanted to say with my comment above: the fact that in a resample operation with product, missing dates end up So it would maybe be possible to change the result of Note: in R, an empty product also gives 1 by definition. |
That's easy to do can just special case the empty product and leave the resample code as is. |
Yes, I meant empty products of series that are empty in the strongest sense (neither values nor missing values). I have no opinion how one best would treat products of a series with only missing values. |
as an aide, you can always do: |
@jreback I do not know if you meant that it would solve the original case, which it does not:
|
@anderslundstedt hmm, empty series is a special case I guess then, ok @cpcloud why don't we just fix the scalar case. What does that do to the resample case? (obvious the test case has to change) |
this is far less trivial than i thought, mostly bc arith methods are added after the class is defined so i can't override it properly. i guess i'll just have to monkey patch it. i have a big refactor of this arith stuff that defines them on ndframe abstractly so that a subclass can override them for specific cases if necessary |
@cpcloud status? |
This is being handled in #18678 |
I excepted:
http://en.wikipedia.org/wiki/Empty_product
The text was updated successfully, but these errors were encountered: