@@ -810,8 +810,14 @@ def _maybe_mask_setitem_value(self, indexer, value):
810
810
811
811
if is_scalar_indexer (icols , self .ndim - 1 ) and ndim == 1 :
812
812
# e.g. test_loc_setitem_boolean_mask_allfalse
813
- # test_loc_setitem_ndframe_values_alignment
814
- value = self .obj .iloc ._align_series (indexer , value )
813
+ if len (newkey ) == 0 :
814
+ # FIXME: kludge for test_loc_setitem_boolean_mask_allfalse
815
+ # TODO(GH#45333): may be fixed when deprecation is enforced
816
+
817
+ value = value .iloc [:0 ]
818
+ else :
819
+ # test_loc_setitem_ndframe_values_alignment
820
+ value = self .obj .iloc ._align_series (indexer , value )
815
821
indexer = (newkey , icols )
816
822
817
823
elif (
@@ -827,8 +833,14 @@ def _maybe_mask_setitem_value(self, indexer, value):
827
833
indexer = (newkey , icols )
828
834
829
835
elif ndim == 2 and value .shape [1 ] == 1 :
830
- # test_loc_setitem_ndframe_values_alignment
831
- value = self .obj .iloc ._align_frame (indexer , value )
836
+ if len (newkey ) == 0 :
837
+ # FIXME: kludge for
838
+ # test_loc_setitem_all_false_boolean_two_blocks
839
+ # TODO(GH#45333): may be fixed when deprecation is enforced
840
+ value = value .iloc [:0 ]
841
+ else :
842
+ # test_loc_setitem_ndframe_values_alignment
843
+ value = self .obj .iloc ._align_frame (indexer , value )
832
844
indexer = (newkey , icols )
833
845
elif com .is_bool_indexer (indexer ):
834
846
indexer = indexer .nonzero ()[0 ]
@@ -2389,7 +2401,7 @@ def ravel(i):
2389
2401
new_ix = Index ([new_ix ])
2390
2402
else :
2391
2403
new_ix = Index (new_ix )
2392
- if ser .index .equals (new_ix ):
2404
+ if ser .index .equals (new_ix ) or not len ( new_ix ) :
2393
2405
if using_cow :
2394
2406
return ser
2395
2407
return ser ._values .copy ()
0 commit comments