Skip to content

Commit 4a5d18d

Browse files
committed
TST: fixed one tests and added two more for pandas-dev#15686
1 parent 84efa45 commit 4a5d18d

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

pandas/tests/indexing/test_iloc.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,33 @@ def test_iloc_setitem_dups(self):
301301
# iloc with a mask aligning from another iloc
302302
df1 = DataFrame([{'A': None, 'B': 1}, {'A': 2, 'B': 2}])
303303
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()
305306

307+
# GH 15686
308+
# iloc with mask, duplicated index and multiple blocks
306309
expected = df.fillna(3)
307-
expected['A'] = expected['A'].astype('float64')
310+
expected.iloc[:, 0] = expected.iloc[:, 0].astype('float64')
308311
inds = np.isnan(df.iloc[:, 0])
309312
mask = inds[inds].index
310313
df.iloc[mask, 0] = df.iloc[mask, 2]
311314
tm.assert_frame_equal(df, expected)
312315

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+
313331
# del a dup column across blocks
314332
expected = DataFrame({0: [1, 2], 1: [3, 4]})
315333
expected.columns = ['B', 'B']

0 commit comments

Comments
 (0)