Skip to content
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
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.16.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Bug Fixes
.. _whatsnew_0160.bug_fixes:

- Fixed compatibility issue in ``DatetimeIndex`` affecting architectures where ``numpy.int_`` defaults to ``numpy.int32`` (:issue:`8943`)

- Bug in Panel indexing with an object-like (:issue:`9140`)



Expand Down
2 changes: 1 addition & 1 deletion pandas/core/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def from_dict(cls, data, intersect=False, orient='items', dtype=None):
def __getitem__(self, key):
if isinstance(self._info_axis, MultiIndex):
return self._getitem_multilevel(key)
if lib.isscalar(key):
if not (_is_list_like(key) or isinstance(key, slice)):
return super(Panel, self).__getitem__(key)
return self.ix[key]

Expand Down
16 changes: 16 additions & 0 deletions pandas/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2448,6 +2448,22 @@ def test_panel_getitem(self):
result = panel.ix[['ItemA','ItemB']]
tm.assert_panel_equal(result,expected)

# with an object-like
# GH 9140
class TestObject:
def __str__(self):
return "TestObject"

obj = TestObject()

p = Panel(np.random.randn(1,5,4), items=[obj],
major_axis = date_range('1/1/2000', periods=5),
minor_axis=['A', 'B', 'C', 'D'])

expected = p.iloc[0]
result = p[obj]
tm.assert_frame_equal(result, expected)

def test_panel_setitem(self):

# GH 7763
Expand Down