Skip to content

Commit 319c4f8

Browse files
committed
REGR: Regression in multi-index indexing with a non-scalar type object (GH7914)
1 parent 912b138 commit 319c4f8

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

doc/source/v0.15.0.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ Bug Fixes
296296
- Bug in adding and subtracting ``PeriodIndex`` with ``PeriodIndex`` raise ``TypeError`` (:issue:`7741`)
297297
- Bug in ``combine_first`` with ``PeriodIndex`` data raises ``TypeError`` (:issue:`3367`)
298298
- Bug in multi-index slicing with missing indexers (:issue:`7866`)
299-
299+
- Regression in multi-index indexing with a non-scalar type object (:issue:`7914`)
300300

301301
- Bug in pickles contains ``DateOffset`` may raise ``AttributeError`` when ``normalize`` attribute is reffered internally (:issue:`7748`)
302302

pandas/core/indexing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ def _getitem_nested_tuple(self, tup):
838838
axis += 1
839839

840840
# if we have a scalar, we are done
841-
if np.isscalar(obj):
841+
if np.isscalar(obj) or not hasattr(obj,'ndim'):
842842
break
843843

844844
# has the dim of the obj changed?

pandas/tests/test_indexing.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,15 @@ def f():
19741974
result = s.loc[idx[:,['foo','bah']]]
19751975
assert_series_equal(result,expected)
19761976

1977+
# regression from < 0.14.0
1978+
# GH 7914
1979+
df = DataFrame([[np.mean, np.median],['mean','median']],
1980+
columns=MultiIndex.from_tuples([('functs','mean'),
1981+
('functs','median')]),
1982+
index=['function', 'name'])
1983+
result = df.loc['function',('functs','mean')]
1984+
self.assertEqual(result,np.mean)
1985+
19771986
def test_setitem_dtype_upcast(self):
19781987

19791988
# GH3216

0 commit comments

Comments
 (0)