@@ -301,15 +301,33 @@ def test_iloc_setitem_dups(self):
301
301
# iloc with a mask aligning from another iloc
302
302
df1 = DataFrame ([{'A' : None , 'B' : 1 }, {'A' : 2 , 'B' : 2 }])
303
303
df2 = DataFrame ([{'A' : 3 , 'B' : 3 }, {'A' : 4 , 'B' : 4 }])
304
- df = concat ([df1 , df2 ], axis = 1 )
304
+ df_orig = concat ([df1 , df2 ], axis = 1 )
305
+ df = df_orig .copy ()
305
306
307
+ # GH 15686
308
+ # iloc with mask, duplicated index and multiple blocks
306
309
expected = df .fillna (3 )
307
- expected [ 'A' ] = expected [ 'A' ].astype ('float64' )
310
+ expected . iloc [:, 0 ] = expected . iloc [:, 0 ].astype ('float64' )
308
311
inds = np .isnan (df .iloc [:, 0 ])
309
312
mask = inds [inds ].index
310
313
df .iloc [mask , 0 ] = df .iloc [mask , 2 ]
311
314
tm .assert_frame_equal (df , expected )
312
315
316
+ # GH 15686
317
+ # iloc with scalar, duplicated index and multiple blocks
318
+ df = df_orig .copy ()
319
+ expected = df .fillna (15 )
320
+ df .iloc [0 , 0 ] = 15
321
+ tm .assert_frame_equal (df , expected )
322
+
323
+ # GH 15686
324
+ # iloc with repeated value, duplicated index and multiple blocks
325
+ df = df_orig .copy ()
326
+ expected = concat ([DataFrame ([{'A' : 15 , 'B' : 1 }, {'A' : 15 , 'B' : 2 }]),
327
+ df2 ], axis = 1 )
328
+ df .iloc [:, 0 ] = 15
329
+ tm .assert_frame_equal (df , expected )
330
+
313
331
# del a dup column across blocks
314
332
expected = DataFrame ({0 : [1 , 2 ], 1 : [3 , 4 ]})
315
333
expected .columns = ['B' , 'B' ]
0 commit comments