Repository: pandas-dev/pandas

Issue:
Negative interger indices lead to  IndexError: indices are out-of-bounds 
The following test case produces `IndexError: indices are out-of-bounds` with negative integers, while positive work fine:

```
testdf = pd.DataFrame({"rna": (1.5,2.2,3.2,4.5),  -1000: [11,21,36,40],0: [10,22,43,34], 1000:[0, 10, 20, 30]})
testdf[[1000]] #this works
testdf[[-1000]] #this does not
```



Discussion:
pls pd.show_versions()

just updated

```
INSTALLED VERSIONS
------------------
commit: None
python: 3.4.3.final.0
python-bits: 64
OS: Darwin
OS-release: 14.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.17.0
nose: 1.3.7
pip: 7.1.2
setuptools: 18.4
Cython: 0.22.1
numpy: 1.10.1
scipy: 0.16.0
statsmodels: None
IPython: 3.2.0
sphinx: 1.3.1
patsy: 0.3.0
dateutil: 2.4.2
pytz: 2015.6
blosc: None
bottleneck: 1.0.0
tables: 3.2.2.dev0
numexpr: 2.4.3
matplotlib: 1.4.3
openpyxl: 2.2.6
xlrd: 0.9.3
xlwt: 1.0.0
xlsxwriter: 0.7.3
lxml: 3.4.4
bs4: 4.3.2
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.5
pymysql: None
psycopg2: 2.6.1 (dt dec pq3 ext lo64)
```

dupe of https://github.com/pydata/pandas/issues/10779
which is fixed in 0.17.0

I do have 0.17.0!

hmm ok will take a look

yep, this is a buggie


Resolving patch:
diff --git a/pandas/core/index.py b/pandas/core/index.py
--- a/pandas/core/index.py
+++ b/pandas/core/index.py
@@ -982,10 +982,6 @@ def _convert_list_indexer(self, keyarr, kind=None):
         if kind in [None, 'iloc', 'ix'] and is_integer_dtype(keyarr) \
            and not self.is_floating() and not isinstance(keyarr, ABCPeriodIndex):
 
-            if self.inferred_type != 'integer':
-                keyarr = np.where(keyarr < 0,
-                                  len(self) + keyarr, keyarr)
-
             if self.inferred_type == 'mixed-integer':
                 indexer = self.get_indexer(keyarr)
                 if (indexer >= 0).all():
@@ -998,6 +994,8 @@ def _convert_list_indexer(self, keyarr, kind=None):
                 return maybe_convert_indices(indexer, len(self))
 
             elif not self.inferred_type == 'integer':
+                keyarr = np.where(keyarr < 0,
+                                  len(self) + keyarr, keyarr)
                 return keyarr
 
         return None


Test patch:
diff --git a/pandas/tests/test_frame.py b/pandas/tests/test_frame.py
--- a/pandas/tests/test_frame.py
+++ b/pandas/tests/test_frame.py
@@ -488,6 +488,18 @@ def test_getitem_ix_mixed_integer(self):
         expected = df.ix[Index([1, 10], dtype=object)]
         assert_frame_equal(result, expected)
 
+        # 11320
+        df = pd.DataFrame({ "rna": (1.5,2.2,3.2,4.5),
+                            -1000: [11,21,36,40],
+                            0: [10,22,43,34],
+                            1000:[0, 10, 20, 30] },columns=['rna',-1000,0,1000])
+        result = df[[1000]]
+        expected = df.iloc[:,[3]]
+        assert_frame_equal(result, expected)
+        result = df[[-1000]]
+        expected = df.iloc[:,[1]]
+        assert_frame_equal(result, expected)
+
     def test_getitem_setitem_ix_negative_integers(self):
         result = self.frame.ix[:, -1]
         assert_series_equal(result, self.frame['D'])