We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent df895ef commit ccd593fCopy full SHA for ccd593f
pandas/core/indexing.py
@@ -825,6 +825,10 @@ def _getitem_nested_tuple(self, tup):
825
obj = getattr(obj, self.name)._getitem_axis(key, axis=axis, validate_iterable=True)
826
axis += 1
827
828
+ # if we have a scalar, we are done
829
+ if np.isscalar(obj):
830
+ break
831
+
832
# has the dim of the obj changed?
833
# GH 7199
834
if obj.ndim < current_ndim:
pandas/tests/test_indexing.py
@@ -611,9 +611,19 @@ def test_loc_setitem_multiindex(self):
611
612
# GH7190
613
index = pd.MultiIndex.from_product([np.arange(0,100), np.arange(0, 80)], names=['time', 'firm'])
614
- df = DataFrame(np.nan,columns=['A', 'w', 'l', 'a', 'x', 'X', 'd', 'profit'], index=index)
615
t, n = 0, 2
616
+ df = DataFrame(np.nan,columns=['A', 'w', 'l', 'a', 'x', 'X', 'd', 'profit'], index=index)
617
+ df.loc[(t,n),'X'] = 0
618
+ result = df.loc[(t,n),'X']
619
+ self.assertEqual(result, 0)
620
621
+ df = DataFrame(-999,columns=['A', 'w', 'l', 'a', 'x', 'X', 'd', 'profit'], index=index)
622
623
624
625
626
+ df = DataFrame(columns=['A', 'w', 'l', 'a', 'x', 'X', 'd', 'profit'], index=index)
627
df.loc[(t,n),'X'] = 0
628
result = df.loc[(t,n),'X']
629
self.assertEqual(result, 0)
0 commit comments