Repository: pandas-dev/pandas

Issue:
BUG: Slicing multi Index with one column by column errors out
The following code errors out. Seems like it should just return the original dataframe.
pandas: 0.13.1-552-g8120a59

``` python
import pandas as pd
import numpy as np
from itertools import product

attributes = ['Attribute' + str(i) for i in range(1)]
attribute_values = ['Value' + str(i) for i in range(1000)]

index = pd.MultiIndex.from_tuples(list(product(attributes, attribute_values)))
df = 0.1 * np.random.randn(10, 1 * 1000) + 0.5
df = pd.DataFrame(df, columns=index)

df[attributes]
```

Stacktrace

```
(pandas)pandas git:master ❯ python example_failure.py                                                                                                                                                                                ✭
Traceback (most recent call last):
  File "example_failure.py", line 12, in <module>
    df[attributes]
  File "PATH/pandas/pandas/core/frame.py", line 1672, in __getitem__
    return self._getitem_array(key)
  File "PATH/pandas/pandas/core/frame.py", line 1717, in _getitem_array
    return self.take(indexer, axis=1, convert=True)
  File "PATH/pandas/pandas/core/generic.py", line 1224, in take
    indices, len(self._get_axis(axis)))
  File "PATH/pandas/pandas/core/indexing.py", line 1564, in _maybe_convert_indices
    if mask.any():
AttributeError: 'bool' object has no attribute 'any'
```



Discussion:
:+1:

@rdooley What version of Python are you running?

```
>>> pandas.show_versions()

INSTALLED VERSIONS
------------------
commit: 8120a5955f912186e6b3913283ffe635474b2581
python: 2.7.3.final.0
python-bits: 32
OS: Linux
OS-release: 3.5.0-48-generic
machine: i686
processor: i686
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.13.1-552-g8120a59
Cython: 0.20.1
numpy: 1.8.1
scipy: None
statsmodels: None
IPython: None
sphinx: None
patsy: None
scikits.timeseries: None
dateutil: 2.2
pytz: 2014.2
bottleneck: None
tables: None
numexpr: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
bq: None
apiclient: None
rpy2: None
sqlalchemy: None
pymysql: None
psycopg2: None
```

This works fine, what would you expect? you are only specifying 1 level

```
In [39]: df['Attribute0']
Out[39]: 
     Value0    Value1    Value2    Value3    Value4    Value5    Value6    Value7    Value8    Value9   Value10   Value11   Value12   Value13   Value14   Value15   Value16   Value17   Value18   Value19   Value20   Value21   Value22   Value23   Value24   Value25   Value26   Value27   Value28  \
0  0.428597  0.474725  0.329974  0.339155  0.510907  0.381153  0.494624  0.459862  0.426424  0.593362  0.477724  0.580565  0.654136  0.402909  0.536322  0.519228  0.603902  0.635411  0.560371  0.372337  0.520917  0.706165  0.529375  0.434004  0.402526  0.403120  0.477703  0.332731  0.515974   
1  0.240495  0.416920  0.439150  0.622330  0.708689  0.438536  0.445845  0.449184  0.312858  0.601184  0.562577  0.375231  0.730649  0.526096  0.597879  0.413970  0.376763  0.275275  0.490993  0.703520  0.563456  0.563306  0.629091  0.471302  0.551040  0.466567  0.431064  0.714665  0.486743   
2  0.331542  0.653771  0.552438  0.589690  0.526086  0.425176  0.434082  0.529349  0.449824  0.505634  0.518366  0.357662  0.497151  0.493554  0.575063  0.512020  0.483671  0.465662  0.466157  0.463028  0.624075  0.504504  0.423229  0.734069  0.651364  0.630627  0.468450  0.328970  0.324258   
3  0.514077  0.427319  0.466188  0.605764  0.428764  0.413647  0.400183  0.485824  0.376856  0.417513  0.464381  0.528675  0.541136  0.433951  0.470221  0.381789  0.327926  0.492118  0.574851  0.589681  0.552885  0.568272  0.367919  0.260071  0.483927  0.521802  0.468524  0.299048  0.647669   
4  0.395979  0.400110  0.409704  0.448312  0.351965  0.609942  0.696743  0.279321  0.461898  0.377576  0.579921  0.420840  0.648152  0.498430  0.407052  0.488687  0.569436  0.381394  0.767291  0.410772  0.470019  0.753922  0.516066  0.419900  0.398174  0.715835  0.323378  0.596044  0.470373   
5  0.526009  0.348792  0.405698  0.404723  0.612659  0.462875  0.473429  0.592034  0.416211  0.534280  0.410594  0.434802  0.675097  0.509855  0.388789  0.438791  0.525251  0.617305  0.391869  0.752799  0.615893  0.557166  0.390778  0.471838  0.581625  0.443952  0.755009  0.551362  0.394231   
6  0.774323  0.472731  0.538965  0.498537  0.460677  0.459545  0.486819  0.597577  0.453321  0.613500  0.602001  0.410832  0.584744  0.458095  0.368004  0.483783  0.423427  0.503754  0.300216  0.540073  0.329496  0.562550  0.380913  0.478411  0.554229  0.369369  0.607680  0.581758  0.513870   
7  0.419491  0.487092  0.406473  0.397357  0.441859  0.511982  0.532354  0.492218  0.443784  0.369556  0.606099  0.478516  0.743081  0.476748  0.491992  0.398343  0.552451  0.477788  0.397714  0.454639  0.304476  0.569097  0.419266  0.300703  0.435237  0.410379  0.625846  0.616154  0.557484   
8  0.394619  0.477231  0.496815  0.360447  0.603958  0.494705  0.483516  0.452920  0.683313  0.393272  0.500985  0.531819  0.441863  0.505411  0.443088  0.651859  0.550723  0.352809  0.490095  0.500648  0.594268  0.481356  0.456229  0.445136  0.376424  0.569474  0.515270  0.546426  0.578490   
9  0.632996  0.444865  0.620693  0.519118  0.526293  0.709014  0.409693  0.669661  0.377818  0.403557  0.490237  0.728029  0.578740  0.384762  0.469213  0.480383  0.669422  0.453744  0.355138  0.565972  0.722325  0.288859  0.492174  0.435719  0.643250  0.521973  0.332801  0.560180  0.559778   

    Value29   Value30   Value31   Value32   Value33   Value34   Value35   Value36   Value37   Value38   Value39   Value40   Value41   Value42   Value43   Value44   Value45   Value46   Value47   Value48   Value49      
0  0.321760  0.592699  0.539722  0.796589  0.422642  0.422434  0.511535  0.401984  0.642769  0.591690  0.618729  0.495701  0.499338  0.563066  0.416714  0.446868  0.452054  0.582336  0.548836  0.447153  0.472968 ...  
1  0.210142  0.449109  0.485753  0.591893  0.385420  0.461945  0.542475  0.384641  0.504033  0.536906  0.306892  0.306667  0.331088  0.580116  0.487420  0.551604  0.541859  0.571688  0.521816  0.406157  0.502571 ...  
2  0.547881  0.360305  0.655494  0.542029  0.566243  0.387138  0.618194  0.450937  0.376648  0.588018  0.585651  0.444006  0.458362  0.350833  0.641674  0.756018  0.433026  0.561242  0.589356  0.451257  0.552501 ...  
3  0.478743  0.547547  0.469112  0.491888  0.594351  0.422536  0.524435  0.482052  0.578267  0.478766  0.349651  0.287340  0.579013  0.392594  0.346863  0.582621  0.501879  0.566547  0.534843  0.463062  0.494592 ...  
4  0.651505  0.492600  0.473807  0.613098  0.424803  0.490984  0.443187  0.622319  0.403338  0.558826  0.483970  0.344612  0.488133  0.415431  0.377388  0.560634  0.538000  0.617297  0.462177  0.496063  0.560822 ...  
5  0.416146  0.448544  0.514729  0.472275  0.347323  0.631208  0.606431  0.442708  0.425733  0.306117  0.323116  0.562519  0.547103  0.681616  0.508262  0.568052  0.583510  0.509279  0.390760  0.499313  0.544170 ...  
6  0.558502  0.396221  0.485368  0.561663  0.541815  0.439916  0.434909  0.557702  0.452810  0.500489  0.394362  0.399809  0.616072  0.409369  0.524609  0.510435  0.431721  0.592443  0.540598  0.571026  0.585635 ...  
7  0.640528  0.442698  0.765788  0.467680  0.334216  0.663389  0.577547  0.415244  0.539227  0.434006  0.363006  0.501987  0.475661  0.423875  0.600613  0.266944  0.297475  0.459295  0.392350  0.732349  0.461073 ...  
8  0.504471  0.473215  0.555433  0.426638  0.356168  0.382980  0.496851  0.459538  0.519070  0.608182  0.489673  0.542196  0.489839  0.679011  0.361691  0.548929  0.703401  0.420543  0.642336  0.446213  0.732407 ...  
9  0.544913  0.439394  0.466272  0.377234  0.515162  0.582319  0.618151  0.552965  0.500832  0.583877  0.365398  0.410493  0.634820  0.674711  0.606125  0.671604  0.531618  0.623165  0.528496  0.637803  0.459427 ...  

[10 rows x 1000 columns]
```

@jreback I'm getting the same error as @rdooley on Python 2.7.5 with `pandas==0.13.1` and `numpy==1.8.0` installed.

you can't pass a list if you only specify a single level of the multi-index.

what are you trying to do?

@jreback That is indeed the intention. In a utility function under most circumstances multiple levels are specified however an edge case where only one level was specified (and also only one level in the multi index) occurred.

ok...take that back...this is a bug....didn't have  a test for it.


Resolving patch:
diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py
--- a/pandas/core/indexing.py
+++ b/pandas/core/indexing.py
@@ -1040,6 +1040,10 @@ def _convert_to_indexer(self, obj, axis=0, is_setter=False):
                     level = 0
                     _, indexer = labels.reindex(objarr, level=level)
 
+                    # take all
+                    if indexer is None:
+                        indexer = np.arange(len(labels))
+
                     check = labels.levels[0].get_indexer(objarr)
                 else:
                     level = None


Test patch:
diff --git a/pandas/tests/test_indexing.py b/pandas/tests/test_indexing.py
--- a/pandas/tests/test_indexing.py
+++ b/pandas/tests/test_indexing.py
@@ -1128,6 +1128,17 @@ def test_loc_multiindex(self):
         xp = mi_int.ix[4]
         assert_frame_equal(rs,xp)
 
+        # GH6788
+        # multi-index indexer is None (meaning take all)
+        attributes = ['Attribute' + str(i) for i in range(1)]
+        attribute_values = ['Value' + str(i) for i in range(5)]
+
+        index = MultiIndex.from_product([attributes,attribute_values])
+        df = 0.1 * np.random.randn(10, 1 * 5) + 0.5
+        df = DataFrame(df, columns=index)
+        result = df[attributes]
+        assert_frame_equal(result, df)
+
     def test_series_getitem_multiindex(self):
 
         # GH 6018