-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
df.ix[] inconsistency between axis for MultiIndex #2904
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
i think with #2922, these make more sense (obviously eg.
|
Hmm, i clearly did not follow the thread in #2922 close enough, since i am surprised by failure of |
close this? going to add to cookbook in any event |
You prefer to close this since On the above DataFrame |
your example probably SHOULD work, but ix is quite tricky, I am not sure there are plans to change/fix it. could certainly bump this to 0.12. if you would like slicing does work on integer multi-index just respects labels or positions depending on what you choose. Your example in this issue is good at showing he ambiguity! am I missing something? |
Ok, we agree that both The label slicing with loc is something else, i don not think i am missing between label and position, it is all label ... however In [38]: df
Out[38]:
10 20 30
a b a b a b
10 a -0.799097 -0.450663 -0.003029 0.340621 -1.248213 -0.900263
b -0.049115 -1.540385 -0.299996 -3.520201 -0.631406 1.036550
20 a -1.051028 -0.952631 2.114734 -0.285703 -1.346419 0.791299
b -1.225570 1.063159 0.731514 -0.153996 0.382094 0.797084
30 a -1.176216 1.235405 -0.226777 0.852648 2.481304 0.587310
b 1.786893 -0.042711 0.742734 -0.041659 2.544889 0.558397
In [40]: df.loc[20:30, :]
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
...
KeyError: 'stop bound [29] is not in the [index]' compare this to In [43]: df
Out[43]:
5 6 7
a b a b a b
5 a -1.312814 -0.839775 0.812328 0.041647 0.231441 0.439760
b -0.102015 2.163313 -0.489461 0.931466 1.168450 1.134386
6 a -0.173297 -0.319528 0.546089 -0.392548 1.034875 1.825187
b 1.201444 -0.195438 0.762748 -0.880005 -0.247503 -0.589713
7 a 0.310798 -0.556815 0.355492 -1.554151 0.677812 -1.798690
b -0.871106 -0.932847 0.678469 -1.226688 0.595985 -0.738877
In [44]: df.loc[6:7, :]
Out[44]:
5 6 7
a b a b a b
6 a -0.173297 -0.319528 0.546089 -0.392548 1.034875 1.825187
b 1.201444 -0.195438 0.762748 -0.880005 -0.247503 -0.589713
7 a 0.310798 -0.556815 0.355492 -1.554151 0.677812 -1.798690
b -0.871106 -0.932847 0.678469 -1.226688 0.595985 -0.738877 |
i think you are right, I am treating the integer slice and expanding it to the integers in the range rather than the labels, so your first example should work, I will file a bug on this. note that it will be an INCLUSIVE range because these are labels |
@lodagro I updated the example...thanks for the catch! |
@jreback We discussed in fact two issues here. One being the ix inconsistency (the reason why this issue was opened), the other one loc failure on integer slices (which are labels iso positions). Loc one is resolved, ix seems to be the same. |
Closing due to deprecation in #15113 |
Slicing ranges is consistent between both axis.
This is inconsistent to me:
and this also
The text was updated successfully, but these errors were encountered: