Skip to content

Commit

Permalink
TST: fixed one tests and added two more for pandas-dev#15686
Browse files Browse the repository at this point in the history
  • Loading branch information
toobaz committed May 13, 2017
1 parent b3096bb commit 99e44d7
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions pandas/tests/indexing/test_iloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,33 @@ def test_iloc_setitem_dups(self):
# iloc with a mask aligning from another iloc
df1 = DataFrame([{'A': None, 'B': 1}, {'A': 2, 'B': 2}])
df2 = DataFrame([{'A': 3, 'B': 3}, {'A': 4, 'B': 4}])
df = concat([df1, df2], axis=1)
df_orig = concat([df1, df2], axis=1)
df = df_orig.copy()

# GH 15686
# iloc with mask, duplicated index and multiple blocks
expected = df.fillna(3)
expected['A'] = expected['A'].astype('float64')
expected.iloc[:, 0] = expected.iloc[:, 0].astype('float64')
inds = np.isnan(df.iloc[:, 0])
mask = inds[inds].index
df.iloc[mask, 0] = df.iloc[mask, 2]
tm.assert_frame_equal(df, expected)

# GH 15686
# iloc with scalar, duplicated index and multiple blocks
df = df_orig.copy()
expected = df.fillna(15)
df.iloc[0, 0] = 15
tm.assert_frame_equal(df, expected)

# GH 15686
# iloc with repeated value, duplicated index and multiple blocks
df = df_orig.copy()
expected = concat([DataFrame([{'A': 15, 'B': 1}, {'A': 15, 'B': 2}]),
df2], axis=1)
df.iloc[:, 0] = 15
tm.assert_frame_equal(df, expected)

# del a dup column across blocks
expected = DataFrame({0: [1, 2], 1: [3, 4]})
expected.columns = ['B', 'B']
Expand Down

0 comments on commit 99e44d7

Please sign in to comment.