@@ -176,7 +176,8 @@ def test_dups_fancy_indexing(self):
176176 'test1' : [7. , 6 , np .nan ],
177177 'other' : ['d' , 'c' , np .nan ]}, index = rows )
178178
179- result = df .loc [rows ]
179+ with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ):
180+ result = df .loc [rows ]
180181 tm .assert_frame_equal (result , expected )
181182
182183 # see GH5553, make sure we use the right indexer
@@ -186,7 +187,8 @@ def test_dups_fancy_indexing(self):
186187 'other' : [np .nan , np .nan , np .nan ,
187188 'd' , 'c' , np .nan ]},
188189 index = rows )
189- result = df .loc [rows ]
190+ with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ):
191+ result = df .loc [rows ]
190192 tm .assert_frame_equal (result , expected )
191193
192194 # inconsistent returns for unique/duplicate indices when values are
@@ -203,20 +205,23 @@ def test_dups_fancy_indexing(self):
203205
204206 # GH 4619; duplicate indexer with missing label
205207 df = DataFrame ({"A" : [0 , 1 , 2 ]})
206- result = df .loc [[0 , 8 , 0 ]]
208+ with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ):
209+ result = df .loc [[0 , 8 , 0 ]]
207210 expected = DataFrame ({"A" : [0 , np .nan , 0 ]}, index = [0 , 8 , 0 ])
208211 tm .assert_frame_equal (result , expected , check_index_type = False )
209212
210213 df = DataFrame ({"A" : list ('abc' )})
211- result = df .loc [[0 , 8 , 0 ]]
214+ with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ):
215+ result = df .loc [[0 , 8 , 0 ]]
212216 expected = DataFrame ({"A" : ['a' , np .nan , 'a' ]}, index = [0 , 8 , 0 ])
213217 tm .assert_frame_equal (result , expected , check_index_type = False )
214218
215219 # non unique with non unique selector
216220 df = DataFrame ({'test' : [5 , 7 , 9 , 11 ]}, index = ['A' , 'A' , 'B' , 'C' ])
217221 expected = DataFrame (
218222 {'test' : [5 , 7 , 5 , 7 , np .nan ]}, index = ['A' , 'A' , 'A' , 'A' , 'E' ])
219- result = df .loc [['A' , 'A' , 'E' ]]
223+ with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ):
224+ result = df .loc [['A' , 'A' , 'E' ]]
220225 tm .assert_frame_equal (result , expected )
221226
222227 # GH 5835
@@ -227,7 +232,8 @@ def test_dups_fancy_indexing(self):
227232 expected = pd .concat (
228233 [df .loc [:, ['A' , 'B' ]], DataFrame (np .nan , columns = ['C' ],
229234 index = df .index )], axis = 1 )
230- result = df .loc [:, ['A' , 'B' , 'C' ]]
235+ with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ):
236+ result = df .loc [:, ['A' , 'B' , 'C' ]]
231237 tm .assert_frame_equal (result , expected )
232238
233239 # GH 6504, multi-axis indexing
0 commit comments