@@ -285,15 +285,33 @@ def test_iloc_setitem_dups(self):
285
285
# iloc with a mask aligning from another iloc
286
286
df1 = DataFrame ([{'A' : None , 'B' : 1 }, {'A' : 2 , 'B' : 2 }])
287
287
df2 = DataFrame ([{'A' : 3 , 'B' : 3 }, {'A' : 4 , 'B' : 4 }])
288
- df = concat ([df1 , df2 ], axis = 1 )
288
+ df_orig = concat ([df1 , df2 ], axis = 1 )
289
+ df = df_orig .copy ()
289
290
291
+ # GH 15686
292
+ # iloc with mask, duplicated index and multiple blocks
290
293
expected = df .fillna (3 )
291
- expected [ 'A' ] = expected [ 'A' ].astype ('float64' )
294
+ expected . iloc [:, 0 ] = expected . iloc [:, 0 ].astype ('float64' )
292
295
inds = np .isnan (df .iloc [:, 0 ])
293
296
mask = inds [inds ].index
294
297
df .iloc [mask , 0 ] = df .iloc [mask , 2 ]
295
298
tm .assert_frame_equal (df , expected )
296
299
300
+ # GH 15686
301
+ # iloc with scalar, duplicated index and multiple blocks
302
+ df = df_orig .copy ()
303
+ expected = df .fillna (15 )
304
+ df .iloc [0 , 0 ] = 15
305
+ tm .assert_frame_equal (df , expected )
306
+
307
+ # GH 15686
308
+ # iloc with repeated value, duplicated index and multiple blocks
309
+ df = df_orig .copy ()
310
+ expected = concat ([DataFrame ([{'A' : 15 , 'B' : 1 }, {'A' : 15 , 'B' : 2 }]),
311
+ df2 ], axis = 1 )
312
+ df .iloc [:, 0 ] = 15
313
+ tm .assert_frame_equal (df , expected )
314
+
297
315
# del a dup column across blocks
298
316
expected = DataFrame ({0 : [1 , 2 ], 1 : [3 , 4 ]})
299
317
expected .columns = ['B' , 'B' ]
0 commit comments