Join GitHub today
Fundamental issue with ix #328
Using square bracket indexing [x] on a Series where x is an integer
KeyError Traceback (most recent call
Is this behaviour intended? To me it seems like a fundamental bug.
From the documentation:
If the labels are made strings, the behaviour is utterly different
This is intended behavior. The whole issue arises because there is confusion when you use integer indices. i.e., when you pass in an integer key x, do you want the item corresponding to key x or the x-th item? The same logic applies in your second example, it's just that there is no item corresponding to key x because x is an integer while your index is all str.
I think you would rather allow a careful user to use integer keys when necessary than automatically converting all integer keys to str. In your second example where you convert the index into str, you would get this behavior: