Repository: pandas-dev/pandas

Issue:
ERR: Raise a better message when mixing positional and label indexing in loc/iloc
#### Code Sample, a copy-pastable example if possible

```python
import numpy as np

data = DataFrame(np.arange(16).reshape((4, 4)),
    index=['Ohio', 'Colorado', 'Utah', 'New York'],
    columns=['one', 'two', 'three', 'four'])

data[data < 5] = 0


print(data.iloc[['Colorado', 'Utah'], [3, 0, 1]])
# .ix is deprecated. Please use
# .loc for label based indexing or
# .iloc for positional indexing


print(data.iloc[['Colorado', 'Utah'], [3, 0, 1]])
#TypeError: cannot perform reduce with flexible type

print(data.loc[['Colorado', 'Utah'], [3, 0, 1]])
#KeyError: "None of [Int64Index([3, 0, 1], dtype='int64')] are in the [columns]"
```
#### Problem description
I followed the suggesion to move the ix to iloc and this is what I have got
I have used python 3.7.2 on an elemntary os 18.04



Discussion:
Mixing positional and label based indexing is not allowed in `loc` or `iloc`.

So either `data.iloc[[1, 2], [3, 0, 1]]` or `data.loc[['Colorado', 'Utah'], ['four', 'one', 'two]]`
@mroeschke : the error message `TypeError: cannot perform reduce with flexible type` does not appear helpful. perhaps this should be raised as a seperate issue.
I am happy with the answer provided.
Just unhappy for this decision becouse It would potentially break old code as soon as ix will be fully deprecated. 

The example cames from data analysis with python book and can be easily reproduced. 
Fair. `iloc` and `loc` could have a better error messages with mixed positional/label indexing.

The decision to deprecate `ix` was made was because its indexing operation was too flexible and not explicit compared to the other multitude of indexers.

Resolving patch:
diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py
--- a/pandas/core/indexing.py
+++ b/pandas/core/indexing.py
@@ -13,7 +13,7 @@
 
 from pandas.core.dtypes.common import (
     ensure_platform_int, is_float, is_integer, is_integer_dtype, is_iterator,
-    is_list_like, is_scalar, is_sequence, is_sparse)
+    is_list_like, is_numeric_dtype, is_scalar, is_sequence, is_sparse)
 from pandas.core.dtypes.generic import ABCDataFrame, ABCPanel, ABCSeries
 from pandas.core.dtypes.missing import _infer_fill_value, isna
 
@@ -2075,10 +2075,15 @@ def _validate_key(self, key, axis):
             # so don't treat a tuple as a valid indexer
             raise IndexingError('Too many indexers')
         elif is_list_like_indexer(key):
-            # check that the key does not exceed the maximum size of the index
             arr = np.array(key)
             len_axis = len(self.obj._get_axis(axis))
 
+            # check that the key has a numeric dtype
+            if not is_numeric_dtype(arr.dtype):
+                raise IndexError(".iloc requires numeric indexers, got "
+                                 "{arr}".format(arr=arr))
+
+            # check that the key does not exceed the maximum size of the index
             if len(arr) and (arr.max() >= len_axis or arr.min() < -len_axis):
                 raise IndexError("positional indexers are out-of-bounds")
         else:


Test patch:
diff --git a/pandas/tests/indexing/test_iloc.py b/pandas/tests/indexing/test_iloc.py
--- a/pandas/tests/indexing/test_iloc.py
+++ b/pandas/tests/indexing/test_iloc.py
@@ -118,6 +118,21 @@ def check(result, expected):
         with pytest.raises(IndexError, match=msg):
             dfl.iloc[:, 4]
 
+    @pytest.mark.parametrize("index,columns", [(np.arange(20), list('ABCDE'))])
+    @pytest.mark.parametrize("index_vals,column_vals", [
+        ([slice(None), ['A', 'D']]),
+        (['1', '2'], slice(None)),
+        ([pd.datetime(2019, 1, 1)], slice(None))])
+    def test_iloc_non_integer_raises(self, index, columns,
+                                     index_vals, column_vals):
+        # GH 25753
+        df = DataFrame(np.random.randn(len(index), len(columns)),
+                       index=index,
+                       columns=columns)
+        msg = '.iloc requires numeric indexers, got'
+        with pytest.raises(IndexError, match=msg):
+            df.iloc[index_vals, column_vals]
+
     def test_iloc_getitem_int(self):
 
         # integer