Skip to content

Commit 74343c2

Browse files
committed
TST: fixed one tests and added two more for pandas-dev#15686
1 parent 15afa37 commit 74343c2

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
@@ -288,15 +288,33 @@ def test_iloc_setitem_dups(self):
288288
# iloc with a mask aligning from another iloc
289289
df1 = DataFrame([{'A': None, 'B': 1}, {'A': 2, 'B': 2}])
290290
df2 = DataFrame([{'A': 3, 'B': 3}, {'A': 4, 'B': 4}])
291-
df = concat([df1, df2], axis=1)
291+
df_orig = concat([df1, df2], axis=1)
292+
df = df_orig.copy()
292293

294+
# GH 15686
295+
# iloc with mask, duplicated index and multiple blocks
293296
expected = df.fillna(3)
294-
expected['A'] = expected['A'].astype('float64')
297+
expected.iloc[:, 0] = expected.iloc[:, 0].astype('float64')
295298
inds = np.isnan(df.iloc[:, 0])
296299
mask = inds[inds].index
297300
df.iloc[mask, 0] = df.iloc[mask, 2]
298301
tm.assert_frame_equal(df, expected)
299302

303+
# GH 15686
304+
# iloc with scalar, duplicated index and multiple blocks
305+
df = df_orig.copy()
306+
expected = df.fillna(15)
307+
df.iloc[0, 0] = 15
308+
tm.assert_frame_equal(df, expected)
309+
310+
# GH 15686
311+
# iloc with repeated value, duplicated index and multiple blocks
312+
df = df_orig.copy()
313+
expected = concat([DataFrame([{'A': 15, 'B': 1}, {'A': 15, 'B': 2}]),
314+
df2], axis=1)
315+
df.iloc[:, 0] = 15
316+
tm.assert_frame_equal(df, expected)
317+
300318
# del a dup column across blocks
301319
expected = DataFrame({0: [1, 2], 1: [3, 4]})
302320
expected.columns = ['B', 'B']

0 commit comments

Comments
 (0)