diff --git a/doc/source/whatsnew/v0.15.1.txt b/doc/source/whatsnew/v0.15.1.txt index 7b3aaa00e7ea9..fd34099ffe75b 100644 --- a/doc/source/whatsnew/v0.15.1.txt +++ b/doc/source/whatsnew/v0.15.1.txt @@ -47,4 +47,7 @@ Experimental Bug Fixes ~~~~~~~~~ + - Bug in ``cut``/``qcut`` when using ``Series`` and ``retbins=True`` (:issue:`8589`) + +- Fix ``shape`` attribute for ``MultiIndex`` (:issue:`8609`) diff --git a/pandas/core/base.py b/pandas/core/base.py index 5d6f39e1792c3..71a08e0dd553d 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -297,7 +297,7 @@ def transpose(self): @property def shape(self): """ return a tuple of the shape of the underlying data """ - return self._data.shape + return self.values.shape @property def ndim(self): diff --git a/pandas/tests/test_index.py b/pandas/tests/test_index.py index 3c5f3a8d6b6d3..daea405a873ae 100644 --- a/pandas/tests/test_index.py +++ b/pandas/tests/test_index.py @@ -83,6 +83,17 @@ def f(): pass tm.assertRaisesRegexp(ValueError,'The truth value of a',f) + def test_ndarray_compat_properties(self): + + idx = self.create_index() + self.assertTrue(idx.T.equals(idx)) + self.assertTrue(idx.transpose().equals(idx)) + + values = idx.values + for prop in ['shape', 'ndim', 'size', 'itemsize', 'nbytes']: + self.assertEqual(getattr(idx, prop), getattr(values, prop)) + + class TestIndex(Base, tm.TestCase): _holder = Index _multiprocess_can_split_ = True