diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 39ddc9a7ee22a..e0c5fa573ff69 100644 --- 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 diff --git a/pandas/tests/test_indexing.py b/pandas/tests/test_indexing.py index 3f6ae24756d47..fe08fb3a957c2 100644 --- 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