-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Now boolean operators work with NDFrames? #4633
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
|
This seems like a good thing. Now truthy-ness of Series/DataFrames is consistent, empty Series are Falsey.
Not sure I can use this anywhere, but I'll try. |
Consistency aside, this seems likely to lead to lots of subtle bugs when people use |
Along the lines of @mtkni's comment : is it a good thing that Series behaves more like a Python container vs a numpy container? |
Ew:
That said, you're probably right that and/or should raise. :( |
You also get fun things like this:
I think it should raise as well. It's doing numpy-like comparisons and broadcasting, not throwing an exception can allow subtle bugs to go undetected. Possibly related: #1069 (old but apparently reverted), #4576, #4537 |
this like this I think are easily caught I had to add a couple of coercion method which can handle these cases eg bool , int etc |
What's the use case for allowing |
oh I agree however we have a couple of tests that would fail otherwise so need to fix those iIIRC there was a couple of places this is relied upon (which is just wrong) @cpcloud pls mark this and we can take a look |
yeh these should all be consistent |
This is from 0.12
master
These are the same in 0.12 and master, e.g. a 1-element Series is special cased
I am going to argue that 0.12 is inconsistent and master is correct However, one could have a point of view that ALL of these should raise any thoughts? |
@wesm ? |
pandas 0.11.0:
To me, it looks like this is the right behavior (with the possible exception of |
I'm strongly of the opinion it should be all or nothing. The numpy behaviour is stupid. |
Changing to this (for all NDFrame, and eliminating the special case from Series)
causes very few failures, (aside from the ones I am purposely testing), really just a couple of test cases that are not formed well e.g. things like these, which are simply incorrect usages....will change the PR and eveyone can look
|
this is a revert to #1073/#1069 now a call to nonzero raises The following is the behavior
And prevents these fun ones (same for Series/Panel)
|
anyone think this should be a |
I think you should change the error message - the numpy error message is |
@jtratner numpy
make the same? I also want to mention |
revised to be the same as numpy |
see revised PR for updates on the error messages |
Awkward side effect of the new and improved
Series
probably, I typed something wrong and was shocked to not get the usualnumpy
ValueError
barf:The text was updated successfully, but these errors were encountered: