-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
Assigning dataframe by specifying both row/col doesn't handle nan correctly #3626
Comments
|
I'm using 0.11. The older version doesn't support this kind of assignment. notice in your test, the mask is inversed, so the null value problem doesn't show up. |
ah..you are right...copy error.....I will take a look, could be a bug in this as I allowed this starting in 0.11 (in theory in certain cases in might have worked < 0.11, that's why I asked) |
@jianpan I updated the results (I switched a range of ints, easier to see alignment), this looks right to me.... (I didn't change any code) |
if you run the df2.ix[mask, cols]= dft.ix[mask, cols] the second time, you will see different result because the bug happens when the left hand side of assignment (df2 in your test) has null values. I updated my first post to include the wrong results. |
this should be closed by #3632 also, if you like to contribute a DOC PR, I had left this issue open #3289 would like to have an example of this (since as of 0.11 we support this) |
Thanks. Can you also check this sample:
This used to fail because in pandas index.py line 149: |
updated the PR, that is correct, was another bug! as you can see was not completely tested (or maybe tests were too naive) this correctly works now ...pls give a try again |
Thanks for the quick fix! |
np... still would love for a PR for the docs for this (really just an example like hav above) |
If I run the following code under pandas 0.11, I will get different results from the 2 identical assign statment at the bottom:
Notice in the second result, the NaN at [3,3] disappeared and all values below it got shifted up.
The issue seems to be in pandas index.py line 143:
v = v.reindex(self.obj[item].reindex(v.index).dropna().index)
notice it's dropping NA from the target.
I then tried to use df.ix[mask, cols]= dft.ix[mask, cols].values to bypass this, and it failed also. The problem is in pandas index.py line 149:
if len(labels) != len(value):
notice it's comparing number of columns to be assigned against number of rows in ndarray.
The text was updated successfully, but these errors were encountered: