Closed
Description
Currently, the following does not work (but probably should):
In [12]: arr1 = pd.array([1, 2, 3])
In [13]: arr2 = pd.array([0, 2])
In [14]: arr1[arr2]
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-14-1646c66d4d26> in <module>
----> 1 arr1[arr2]
~/scipy/pandas/pandas/core/arrays/integer.py in __getitem__(self, item)
375 item = check_bool_array_indexer(self, item)
376
--> 377 return type(self)(self._data[item], self._mask[item])
378
379 def _coerce_to_ndarray(self, dtype=None, na_value=lib._no_default):
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
So that raises the following questions:
- This should probably simply work for the above case? (converting the IntegerArray to a numpy integer array, instead of object array, so numpy's indexing works) We might want to combine this with the boolean array checking?
- What if there are missing values? This should probably simply raise an error for now (which is what pandas 0.25 also does), although we could consider propagating an NA value as well, I think.
For Series, this seems to work partly. For iloc
it works for the case without missing values. For __getitem__
you get the same error as above.