@@ -1662,25 +1662,6 @@ def orig(self):
16621662 orig = DataFrame ({"cats" : cats , "values" : values }, index = idx )
16631663 return orig
16641664
1665- @pytest .fixture
1666- def exp_single_row (self ):
1667- # The expected values if we change a single row
1668- cats1 = Categorical (["a" , "a" , "b" , "a" , "a" , "a" , "a" ], categories = ["a" , "b" ])
1669- idx1 = Index (["h" , "i" , "j" , "k" , "l" , "m" , "n" ])
1670- values1 = [1 , 1 , 2 , 1 , 1 , 1 , 1 ]
1671- exp_single_row = DataFrame ({"cats" : cats1 , "values" : values1 }, index = idx1 )
1672- return exp_single_row
1673-
1674- @pytest .fixture
1675- def exp_multi_row (self ):
1676- # assign multiple rows (mixed values) (-> array) -> exp_multi_row
1677- # changed multiple rows
1678- cats2 = Categorical (["a" , "a" , "b" , "b" , "a" , "a" , "a" ], categories = ["a" , "b" ])
1679- idx2 = Index (["h" , "i" , "j" , "k" , "l" , "m" , "n" ])
1680- values2 = [1 , 1 , 2 , 2 , 1 , 1 , 1 ]
1681- exp_multi_row = DataFrame ({"cats" : cats2 , "values" : values2 }, index = idx2 )
1682- return exp_multi_row
1683-
16841665 @pytest .fixture
16851666 def exp_parts_cats_col (self ):
16861667 # changed part of the cats column
@@ -1702,7 +1683,7 @@ def exp_single_cats_value(self):
17021683 return exp_single_cats_value
17031684
17041685 @pytest .mark .parametrize ("indexer" , [tm .loc , tm .iloc ])
1705- def test_loc_iloc_setitem_list_of_lists (self , orig , exp_multi_row , indexer ):
1686+ def test_loc_iloc_setitem_list_of_lists (self , orig , indexer ):
17061687 # - assign multiple rows (mixed values) -> exp_multi_row
17071688 df = orig .copy ()
17081689
@@ -1711,6 +1692,11 @@ def test_loc_iloc_setitem_list_of_lists(self, orig, exp_multi_row, indexer):
17111692 key = slice ("j" , "k" )
17121693
17131694 indexer (df )[key , :] = [["b" , 2 ], ["b" , 2 ]]
1695+
1696+ cats2 = Categorical (["a" , "a" , "b" , "b" , "a" , "a" , "a" ], categories = ["a" , "b" ])
1697+ idx2 = Index (["h" , "i" , "j" , "k" , "l" , "m" , "n" ])
1698+ values2 = [1 , 1 , 2 , 2 , 1 , 1 , 1 ]
1699+ exp_multi_row = DataFrame ({"cats" : cats2 , "values" : values2 }, index = idx2 )
17141700 tm .assert_frame_equal (df , exp_multi_row )
17151701
17161702 df = orig .copy ()
@@ -1752,9 +1738,7 @@ def test_loc_iloc_setitem_mask_single_value_in_categories(
17521738 tm .assert_frame_equal (df , exp_single_cats_value )
17531739
17541740 @pytest .mark .parametrize ("indexer" , [tm .loc , tm .iloc ])
1755- def test_loc_iloc_setitem_full_row_non_categorical_rhs (
1756- self , orig , exp_single_row , indexer
1757- ):
1741+ def test_loc_iloc_setitem_full_row_non_categorical_rhs (self , orig , indexer ):
17581742 # - assign a complete row (mixed values) -> exp_single_row
17591743 df = orig .copy ()
17601744
@@ -1764,6 +1748,10 @@ def test_loc_iloc_setitem_full_row_non_categorical_rhs(
17641748
17651749 # not categorical dtype, but "b" _is_ among the categories for df["cat"]
17661750 indexer (df )[key , :] = ["b" , 2 ]
1751+ cats1 = Categorical (["a" , "a" , "b" , "a" , "a" , "a" , "a" ], categories = ["a" , "b" ])
1752+ idx1 = Index (["h" , "i" , "j" , "k" , "l" , "m" , "n" ])
1753+ values1 = [1 , 1 , 2 , 1 , 1 , 1 , 1 ]
1754+ exp_single_row = DataFrame ({"cats" : cats1 , "values" : values1 }, index = idx1 )
17671755 tm .assert_frame_equal (df , exp_single_row )
17681756
17691757 # "c" is not among the categories for df["cat"]
0 commit comments