@@ -3298,21 +3298,21 @@ def test_loc_reindexing_of_empty_index(self):
32983298 expected = DataFrame (index = [1 , 1 , 2 , 2 ], data = ["1" , "1" , "2" , "2" ])
32993299 tm .assert_frame_equal (df , expected )
33003300
3301- def test_loc_setitem_matching_index (self ,series_with_simple_index ):
3301+ def test_loc_setitem_matching_index (self , series_with_simple_index ):
33023302 # GH 25548
3303- ser1 = series_with_simple_index .copy ()
3304- ser1 = ser1 [~ ser1 .index .duplicated (keep = ' first' )]
3305- ser2 = ser1 .copy ()
3303+ ser1 = series_with_simple_index .copy ()
3304+ ser1 = ser1 [~ ser1 .index .duplicated (keep = " first" )]
3305+ ser2 = ser1 .copy ()
33063306 # Testing on upto 2 indices
3307- for nsize in range (1 ,min (len (ser1 ),3 )):
3308- random_sample = ser1 .sample (n = nsize )
3309- matching_mask = ser1 .index .isin (random_sample .index )
3307+ for nsize in range (1 , min (len (ser1 ), 3 )):
3308+ random_sample = ser1 .sample (n = nsize )
3309+ matching_mask = ser1 .index .isin (random_sample .index )
33103310 # Remove values at indices to test assignment
3311- ser1 .loc [matching_mask ]= np .NaN
3312- ser1 .loc [matching_mask ]= random_sample
3313- tm .assert_series_equal (ser1 ,ser2 )
3314- #exclude row and index and test assignment of unmatched indices
3315- exclude_mask = ~ matching_mask
3316- ser2 .loc [matching_mask ]= ser1 .loc [exclude_mask ]
3317- ser1 .loc [matching_mask ]= np .NaN
3318- tm .assert_series_equal (ser2 ,ser1 )
3311+ ser1 .loc [matching_mask ] = np .NaN
3312+ ser1 .loc [matching_mask ] = random_sample
3313+ tm .assert_series_equal (ser1 , ser2 )
3314+ # exclude row and index and test assignment of unmatched indices
3315+ exclude_mask = ~ matching_mask
3316+ ser2 .loc [matching_mask ] = ser1 .loc [exclude_mask ]
3317+ ser1 .loc [matching_mask ] = np .NaN
3318+ tm .assert_series_equal (ser2 , ser1 )
0 commit comments