-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
.ix strange bug for float index #780
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
Thanks for the quick fix. I was going to comment on another issue on float based slicing, but I saw that you had it fixed in commit bc1932f. Now the float based slicing works as expected when the floats are whole numbers. For example, df.ix[2.0:5.0] is considered label-based as promised in the documentation. However, if I mix integer and float then: df.ix[2:5.0] is interpretated as interger-based; I am worried that it may introduce subtle bugs (admittedly, it's bad practice to mix integer and float.) |
There is definitely still some weirdness in slicing. It's been a game of whack-a-mole. Part of the complexity is that slicing is context-dependent on what's in the index. I believe the slicing you point out will be consistent as long as the index type doesn't change ... what I mean is:
This is a bit surprising, that depending on where in the index you slice, you get integer or label based. I think that maybe the index shouldn't change types when it is subsetted (ie, if it's not an Int64Index, should never become one when sliced). Furthermore, from the docs: "Therefore, advanced indexing with .ix will always attempt label-based indexing, before falling back on integer-based indexing." This doesn't seem to be true per the last output, may need fixing here. |
Fix pandas-dev#777: Handle zero columns when converting to unicode
In [1]: import pandas
In [2]: index = [52195.504153, 52196.303147, 52198.369883]
In [3]: a = pandas.DataFrame(randn(3, 2), index)
In [4]: a
Out[4]:
0 1
52195.504153 1.367681 0.243237
52196.303147 -0.745796 -1.054106
52198.369883 -1.462461 -0.683286
In [5]: a.ix[52195.:52196.]
Out[5]:
Empty DataFrame
Columns: array([0, 1])
Index: array([], dtype=object)
In [6]: a.ix[52195.1:52196.5]
Out[6]:
Empty DataFrame
Columns: array([0, 1])
Index: array([], dtype=object)
In [7]: a.ix[52195.1:52196.6]
Out[7]:
0 1
52195.504153 1.367681 0.243237
52196.303147 -0.745796 -1.054106
The text was updated successfully, but these errors were encountered: