Repository: pandas-dev/pandas

Issue:
Cannot use .ix in IntervaIndex('pandas._libs.interval.IntervalTree' object has no attribute 'get_value')
#### Code Sample, a copy-pastable example if possible


```python
x = pd.Series([-2.801298, -2.882724, -3.007899, -2.704554, -3.398761, -2.805034, -2.87554, -2.805034, -2.886459, -2.471618])
y= pd.Series([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
init_cut = pd.qcut(x, 5, duplicates='drop')
retbin = pd.Series(init_cut.values.categories).sort_values()
retbin.iloc[0] = pd.Interval(-np.inf, retbin.iloc[0].right)
retbin.iloc[-1] = pd.Interval(retbin.iloc[-1].left, np.inf)
init_cut = pd.cut(x, pd.IntervalIndex(retbin))
init_cut = init_cut.astype(object)
bin_df = pd.crosstab(index=init_cut, columns=y)
bin_df = bin_df.reindex(retbin)
bin_df = bin_df.sort_index()
bin_df = bin_df.fillna(0.0)
bin_df['nbin'] = np.nan
```

#### Problem description
bin_df = 
col_0             0  nbin
(-inf, -2.911]    2   NaN
(-2.911, -2.878]  2   NaN
(-2.878, -2.805]  3   NaN
(-2.805, -2.782]  1   NaN
(-2.782, inf]     2   NaN


if I use bin_df.ix[0:2,0], I got an error like:

```pytb
Traceback (most recent call last):
  File "D:\anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 2961, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-12-1ae8ba69565c>", line 1, in <module>
    bin_df.ix[0:1,'nbin']
  File "D:\PyTest\venv\lib\site-packages\pandas\core\indexing.py", line 125, in __getitem__
    values = self.obj._get_value(*key)
  File "D:\PyTest\venv\lib\site-packages\pandas\core\frame.py", line 2827, in _get_value
    return engine.get_value(series._values, index)
AttributeError: 'pandas._libs.interval.IntervalTree' object has no attribute 'get_value'
```


the version is 0.25.0
but it works well in 0.24.x

#### Expected Output

#### Output of ``pd.show_versions()``

<details>

[paste the output of ``pd.show_versions()`` here below this line]

</details>



Discussion:
In fact I've got another problem beside, I cannot use:
init_cut = init_cut.astype(pd.Interval)
I've got another error:
Traceback (most recent call last):
  File "D:\anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 2961, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-14-614614131098>", line 1, in <module>
    init_cut.astype(pd.Interval)
  File "D:\PyTest\venv\lib\site-packages\pandas\core\generic.py", line 5883, in astype
    dtype=dtype, copy=copy, errors=errors, **kwargs
  File "D:\PyTest\venv\lib\site-packages\pandas\core\internals\managers.py", line 581, in astype
    return self.apply("astype", dtype=dtype, **kwargs)
  File "D:\PyTest\venv\lib\site-packages\pandas\core\internals\managers.py", line 438, in apply
    applied = getattr(b, f)(**kwargs)
  File "D:\PyTest\venv\lib\site-packages\pandas\core\internals\blocks.py", line 557, in astype
    return self._astype(dtype, copy=copy, errors=errors, values=values, **kwargs)
  File "D:\PyTest\venv\lib\site-packages\pandas\core\internals\blocks.py", line 612, in _astype
    dtype = pandas_dtype(dtype)
  File "D:\PyTest\venv\lib\site-packages\pandas\core\dtypes\common.py", line 2067, in pandas_dtype
    raise TypeError("dtype '{}' not understood".format(dtype))
TypeError: dtype '<class 'pandas._libs.interval.Interval'>' not understood

which is ok in version 0.23.4
but error in version 0.24.x and later version
Any  can help me....

Resolving patch:
diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py
--- a/pandas/core/indexing.py
+++ b/pandas/core/indexing.py
@@ -124,7 +124,7 @@ def __getitem__(self, key):
             key = tuple(com.apply_if_callable(x, self.obj) for x in key)
             try:
                 values = self.obj._get_value(*key)
-            except (KeyError, TypeError, InvalidIndexError):
+            except (KeyError, TypeError, InvalidIndexError, AttributeError):
                 # TypeError occurs here if the key has non-hashable entries,
                 #  generally slice or list.
                 # TODO(ix): most/all of the TypeError cases here are for ix,
@@ -132,6 +132,9 @@ def __getitem__(self, key):
                 # The InvalidIndexError is only catched for compatibility
                 #  with geopandas, see
                 #  https://github.com/pandas-dev/pandas/issues/27258
+                # TODO: The AttributeError is for IntervalIndex which
+                #  incorrectly implements get_value, see
+                #  https://github.com/pandas-dev/pandas/issues/27865
                 pass
             else:
                 if is_scalar(values):


Test patch:
diff --git a/pandas/tests/indexing/test_ix.py b/pandas/tests/indexing/test_ix.py
--- a/pandas/tests/indexing/test_ix.py
+++ b/pandas/tests/indexing/test_ix.py
@@ -343,3 +343,13 @@ def test_ix_duplicate_returns_series(self):
             r = df.ix[0.2, "a"]
         e = df.loc[0.2, "a"]
         tm.assert_series_equal(r, e)
+
+    def test_ix_intervalindex(self):
+        # https://github.com/pandas-dev/pandas/issues/27865
+        df = DataFrame(
+            np.random.randn(5, 2),
+            index=pd.IntervalIndex.from_breaks([-np.inf, 0, 1, 2, 3, np.inf]),
+        )
+        result = df.ix[0:2, 0]
+        expected = df.iloc[0:2, 0]
+        tm.assert_series_equal(result, expected)