-
-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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 using df.loc and unsorted labels doesn't put values in the right places #6254
Comments
yep....this slipped thru (was trying to fix another case).. as a work around you can make the rhs a Series (with the correct indexes) |
@sadruddin thanks for the report! |
And thank you for fixing bugs so quickly! |
this is a corner case |
The workaround is clear and simple, not arguing about that, I'm just saying that the likelihood of someone else getting caught by that is not small, especially given that it doesn't raise any error or warning, but just silently misplaces the elements |
it's a really small corner case and require that the entire column be replaced 0.14 is the next release Ann is soon |
I think i ran into a related bug (at least i ran into it with 0.13.1, but seems fixed with master): import pandas
import numpy as np
x = pandas.DataFrame(np.random.randn(3,3))
y = pandas.DataFrame(np.random.randn(3,3),index=[2,0,1],columns=[0,1,2])
x.ix[y.index,y.columns] = y
print np.linalg.norm(y - x) this will print a nonzero value, but it shouldn't. Just wanted to add this data point, in case it can be used to motivate a 0.13.2 bugfix release. thanks very much |
Using 0.13.1 (gohlke binaries, Win64, using numpy 1.8):
When using .loc, when passing unsorted labels, pandas doesn't assign the values in the designed labels' locations. Example:
df = pandas.DataFrame(index=[3, 5, 4], columns=['A'])
df.loc[[4, 3, 5], 'A'] = [1, 2, 3]
Result is:
One would have expected:
The text was updated successfully, but these errors were encountered: