-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Boolean indexed assignment #4192
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
It appears that this issue is a side effect of #2745. |
this is very tricky...trying to do the right thing in all cases |
go ahead and try the fix, the existing tests should catch if you change the behavior.... but I am thinking
works by accident (as 0 * 2 == 0).... |
I can't see what was the original code trying to achieve there. At no point before does it ensure that |
Or rather, I see what it was trying to achieve, but I can't see why it was doing it the way it is written :) |
Ok, I'll do the fix and add a bunch of tests. I'll try to think of some other edge cases as well. |
great! always nice to have more tests |
Any chance of shipping this in 0.12? When is the deadline for submissions? This is a pretty nasty one and I'd like to make sure 0.12 isn't affected by it. |
sure....do it quick! (should be straightforward) |
Take the simple example below:
The expectation would be that the first item in the series will be set to 2. Unfortunately due to a bug in broadcasting, pandas will set the first item in the series to 2*len(s). The culprit appears to be the below code (series.py:757 - where() method definition):
other
in this case is the length 1 array we need to broadcast. I believe the code made the assumption that other will be perhaps a list of lists? As it stands, this code will take the single element out of the array, multiply it by the length of the series and then carry out the update.I propose that we fix this by using np.repeat which does the correct thing (pending testing).
The text was updated successfully, but these errors were encountered: