Skip to content

Commit 50f0959

Browse files
committed
Merge pull request #7921 from jreback/mi_index
REGR: Regression in multi-index indexing with a non-scalar type object (GH7914)
2 parents d50a729 + 319c4f8 commit 50f0959

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

doc/source/v0.15.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ Bug Fixes
295295
- Bug in adding and subtracting ``PeriodIndex`` with ``PeriodIndex`` raise ``TypeError`` (:issue:`7741`)
296296
- Bug in ``combine_first`` with ``PeriodIndex`` data raises ``TypeError`` (:issue:`3367`)
297297
- Bug in multi-index slicing with missing indexers (:issue:`7866`)
298-
298+
- Regression in multi-index indexing with a non-scalar type object (:issue:`7914`)
299299

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

pandas/core/indexing.py

+1-1
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

+9
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)