-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Using boolean Series to mask array broken in 0.13 #5776
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
Here are 2 workarounds
This doesn't work because of how numpy treats 'foreign' arrays; it basically calls getitem on each element (a) this is quite slow, (b) this might work depending exactly which values are True. This is actually a pretty odd thing to do; why is x not simply a Series as well? (I know it works in 0.12, but that is because Series is a direct sub-class of ndarray and so numpy treats it differently). |
Because there are lots of way of initializing some new data ( I realize the workaround is simple, I'm just annoyed because it's going to have to be applied on an ad hoc basis each time I run into this pattern and have broken code. But I understand if it's an unavoidable/a problem on the numpy side. |
I always use series/data frames as it makes things simpler sometimes it's tricky to know how numpy treats foreign arrays as much of its access is c code so not so so easy to step thru going to take a look at this some more as I think it should work (could be a bug on numpy side or possibly need some access method on a series) |
I think the full set we need to implement are: *array_interface And I think most can just be delegated |
these r just tried in turn |
so numpy does I would actually say this is an interface issue from numpy side. It should just see if its duck typed (after doing the current checks), because Series certainly emulates all aspects of the array. (e.g. if should just check if |
Ok sounds very reasonable, thanks for looking into it and feel free to close |
Hi, I'm testing out some code on the 0.13 release candidate and I've run into problems with a fairly common (for me) pattern. It's no longer possible to use a boolean Series to index a numpy array. E.g.:
Raises:
Perhaps this is not a good idiom, but this change breaks quite a bit of existing code.
The text was updated successfully, but these errors were encountered: