Skip to content

Fix shape attribute for MultiIndex #8609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/source/whatsnew/v0.15.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
2 changes: 1 addition & 1 deletion pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
11 changes: 11 additions & 0 deletions pandas/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down