Skip to content

Commit d7386f0

Browse files
committed
fixed test as per comments
1 parent abc4591 commit d7386f0

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

pandas/tests/indexing/test_iloc.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,15 @@ def test_iloc_setitem(self):
270270
tm.assert_series_equal(s, expected)
271271

272272
@pytest.mark.parametrize(
273-
"data, indexes, values, expected_k", [
274-
([[1, 22, 5], [1, 33, 6]], [0, -1, 1], [2, 3, 1], [7, 10]),
273+
'data, indexes, values, expected_k', [
274+
# test without indexer value in first level of MultiIndex
275275
([[2, 22, 5], [2, 33, 6]], [0, -1, 1], [2, 3, 1], [7, 10]),
276-
([[1, 3, 7], [2, 4, 8]], [0, -1, 1], [1, 1, 10], [8, 19]),
276+
# test like code sample 1 in the issue
277+
([[1, 22, 555], [1, 33, 666]], [0, -1, 1], [200, 300, 100],
278+
[755, 1066]),
279+
# test like code sample 2 in the issue
280+
([[1, 3, 7], [2, 4, 8]], [0, -1, 1], [10, 10, 1000], [17, 1018]),
281+
# test like code sample 3 in the issue
277282
([[1, 11, 4], [2, 22, 5], [3, 33, 6]], [0, -1, 1], [4, 7, 10],
278283
[8, 15, 13])
279284
])
@@ -283,14 +288,14 @@ def test_iloc_setitem_int_multiindex_series(
283288
df = pd.DataFrame(
284289
data=data,
285290
columns=['i', 'j', 'k'])
286-
df.set_index(['i', 'j'], inplace=True)
291+
df = df.set_index(['i', 'j'])
287292

288293
series = df.k.copy()
289294
for i, v in zip(indexes, values):
290295
series.iloc[i] += v
291296

292-
df.k = expected_k
293-
expected = df.k.copy()
297+
df['k'] = expected_k
298+
expected = df.k
294299
tm.assert_series_equal(series, expected)
295300

296301
def test_iloc_setitem_list(self):

0 commit comments

Comments
 (0)