@@ -597,17 +597,13 @@ def test_loc_setitem_frame_with_reindex(self, using_array_manager):
597
597
ser = Series ([2 , 3 , 1 ], index = [3 , 5 , 4 ], dtype = float )
598
598
if using_array_manager :
599
599
# TODO(ArrayManager) with "split" path, we still overwrite the column
600
- # and therefore don't take the order of the indexer into account
601
- ser = Series ([1 , 2 , 3 ], index = [3 , 5 , 4 ], dtype = "int64" )
600
+ # and therefore don't take the dtype of the underlying object into account
601
+ ser = Series ([2 , 3 , 1 ], index = [3 , 5 , 4 ], dtype = "int64" )
602
602
expected = DataFrame ({"A" : ser })
603
603
tm .assert_frame_equal (df , expected )
604
604
605
- @pytest .mark .xfail (reason = "split path wrong update - GH40480" )
606
605
def test_loc_setitem_frame_with_reindex_mixed (self ):
607
- # same test as above, but with mixed dataframe
608
- # TODO with "split" path we still actually overwrite the column
609
- # and therefore don't take the order of the indexer into account
610
- # -> this is a bug: https://github.com/pandas-dev/pandas/issues/40480
606
+ # GH#40480
611
607
df = DataFrame (index = [3 , 5 , 4 ], columns = ["A" , "B" ], dtype = float )
612
608
df ["B" ] = "string"
613
609
df .loc [[4 , 3 , 5 ], "A" ] = np .array ([1 , 2 , 3 ], dtype = "int64" )
@@ -616,8 +612,16 @@ def test_loc_setitem_frame_with_reindex_mixed(self):
616
612
expected ["B" ] = "string"
617
613
tm .assert_frame_equal (df , expected )
618
614
615
+ def test_loc_setitem_frame_with_inverted_slice (self ):
616
+ # GH#40480
617
+ df = DataFrame (index = [1 , 2 , 3 ], columns = ["A" , "B" ], dtype = float )
618
+ df ["B" ] = "string"
619
+ df .loc [slice (3 , 0 , - 1 ), "A" ] = np .array ([1 , 2 , 3 ], dtype = "int64" )
620
+ expected = DataFrame ({"A" : [3 , 2 , 1 ], "B" : "string" }, index = [1 , 2 , 3 ])
621
+ tm .assert_frame_equal (df , expected )
622
+
619
623
# TODO(ArrayManager) "split" path overwrites column and therefore don't take
620
- # the order of the indexer into account
624
+ # the dtype of the underlying object into account
621
625
@td .skip_array_manager_not_yet_implemented
622
626
def test_loc_setitem_empty_frame (self ):
623
627
# GH#6252 setting with an empty frame
0 commit comments