-
-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
DataFrame.ix[n] for numerical (float) indices has an error #707
Comments
I'm not confident this is bug, just a very confusing circumstance. The index is of type float. You are indexing by an integer, however. So df.ix[1] is taking the integer index (offset 1). You really want df.ix[1.], which is the label index (offset 2). In [12]: df.ix[1.] |
I'll leave open to see what Wes has to say. This could be either be a nasty gotcha we should document, or could maybe be something we'd want to disallow (ie, integer indexing in float-based index) |
I think the bug is that it gets and sets different locations in the DataFrame. Why wouldn't it be consistent? On Jan 27, 2012, at 8:24 PM, Adam Kleinreply@reply.github.com wrote:
|
Ah yes, this seems like a bug, the inconsistency of how it treats the .ix integer parameter on getting vs setting (in the context of a float index). |
latest commit should fix. great catch. |
So my understanding for a DataFrame with numerical indices, DataFrame.ix[i] indexes to the position where index=i, and not the ith row of the DataFrame. Although I find this to be confusing, i accept that this was the decision that was made.
However, the getting and setting with .ix is not consistent
from pandas import DataFrame
df = DataFrame(['a','b','c'],index=[0,0.5,1])
df.ix[1] = 'zoo'
print df.ix[1]
Current:
'b'
Expected:
'zoo'
Basically, df.ix[1] returns 'b', of index 0.5, instead of 'zoo' of index 1
The text was updated successfully, but these errors were encountered: