Closed
Description
In the gotchas documentation, in the section "Reindex versus ix gotchas", there is the following example:
In [28]: s = pd.Series([1, 2, 3], index=['a', 0, 1])
In [29]: s
Out[29]:
a 1
0 2
1 3
dtype: int64
In [30]: s.ix[[0, 1]]
Out[30]:
0 2
1 3
dtype: int64
In [31]: s.reindex([0, 1])
Out[31]:
0 2
1 3
dtype: int64
The example shows both ix
and reindex
behaving the same. The subsequent text, however, states that they are expected to give different results:
Because the index in this case does not contain solely integers,
ix
falls back on integer indexing. By contrast,reindex
only looks for the values passed in the index, thus finding the integers0
and1
.
I am not sure if the indexing behaviour is correct and the documentation is wrong, or vice versa. It appears that in this case ix
does not fall back on integer indexing while the text states that it does.