Skip to content

Commit cbdd91a

Browse files
committed
TST: fixed one tests and added two more for pandas-dev#15686
1 parent 9ae43ba commit cbdd91a

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
@@ -285,15 +285,33 @@ def test_iloc_setitem_dups(self):
285285
# iloc with a mask aligning from another iloc
286286
df1 = DataFrame([{'A': None, 'B': 1}, {'A': 2, 'B': 2}])
287287
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()
289290

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

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

0 commit comments

Comments
 (0)