From 7001c993b5d6e38b50c68b7b93b783aac6488c96 Mon Sep 17 00:00:00 2001 From: Andreas Berneryd Date: Sun, 20 Aug 2017 23:08:11 +0200 Subject: [PATCH] fixed test as per comments --- pandas/tests/indexing/test_iloc.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pandas/tests/indexing/test_iloc.py b/pandas/tests/indexing/test_iloc.py index 8a8c12b925f213..4407b6db1c69b6 100644 --- a/pandas/tests/indexing/test_iloc.py +++ b/pandas/tests/indexing/test_iloc.py @@ -270,10 +270,15 @@ def test_iloc_setitem(self): tm.assert_series_equal(s, expected) @pytest.mark.parametrize( - "data, indexes, values, expected_k", [ - ([[1, 22, 5], [1, 33, 6]], [0, -1, 1], [2, 3, 1], [7, 10]), + 'data, indexes, values, expected_k', [ + # test without indexer value in first level of multiindex ([[2, 22, 5], [2, 33, 6]], [0, -1, 1], [2, 3, 1], [7, 10]), - ([[1, 3, 7], [2, 4, 8]], [0, -1, 1], [1, 1, 10], [8, 19]), + # test like code sample 1 in the issue + ([[1, 22, 555], [1, 33, 666]], [0, -1, 1], [200, 300, 100], + [755, 1066]), + # test like code sample 2 in the issue + ([[1, 3, 7], [2, 4, 8]], [0, -1, 1], [10, 10, 1000], [17, 1018]), + # test like code sample 3 in the issue ([[1, 11, 4], [2, 22, 5], [3, 33, 6]], [0, -1, 1], [4, 7, 10], [8, 15, 13]) ]) @@ -283,14 +288,14 @@ def test_iloc_setitem_int_multiindex_series( df = pd.DataFrame( data=data, columns=['i', 'j', 'k']) - df.set_index(['i', 'j'], inplace=True) + df = df.set_index(['i', 'j']) series = df.k.copy() for i, v in zip(indexes, values): series.iloc[i] += v - df.k = expected_k - expected = df.k.copy() + df['k'] = expected_k + expected = df.k tm.assert_series_equal(series, expected) def test_iloc_setitem_list(self):