@@ -41,13 +41,13 @@ def test_setitem_cache_updating(self):
41
41
42
42
# ref the cache
43
43
if do_ref :
44
- df .ix [0 , "c" ]
44
+ df .loc [0 , "c" ]
45
45
46
46
# set it
47
- df .ix [7 , 'c' ] = 1
47
+ df .loc [7 , 'c' ] = 1
48
48
49
- self .assertEqual (df .ix [0 , 'c' ], 0.0 )
50
- self .assertEqual (df .ix [7 , 'c' ], 1.0 )
49
+ self .assertEqual (df .loc [0 , 'c' ], 0.0 )
50
+ self .assertEqual (df .loc [7 , 'c' ], 1.0 )
51
51
52
52
# GH 7084
53
53
# not updating cache on series setting with slices
@@ -226,21 +226,21 @@ def random_text(nobs=100):
226
226
227
227
# explicity copy
228
228
indexer = df .letters .apply (lambda x : len (x ) > 10 )
229
- df = df .ix [indexer ].copy ()
229
+ df = df .loc [indexer ].copy ()
230
230
self .assertIsNone (df .is_copy )
231
231
df ['letters' ] = df ['letters' ].apply (str .lower )
232
232
233
233
# implicity take
234
234
df = random_text (100000 )
235
235
indexer = df .letters .apply (lambda x : len (x ) > 10 )
236
- df = df .ix [indexer ]
236
+ df = df .loc [indexer ]
237
237
self .assertIsNotNone (df .is_copy )
238
238
df ['letters' ] = df ['letters' ].apply (str .lower )
239
239
240
240
# implicity take 2
241
241
df = random_text (100000 )
242
242
indexer = df .letters .apply (lambda x : len (x ) > 10 )
243
- df = df .ix [indexer ]
243
+ df = df .loc [indexer ]
244
244
self .assertIsNotNone (df .is_copy )
245
245
df .loc [:, 'letters' ] = df ['letters' ].apply (str .lower )
246
246
@@ -251,7 +251,7 @@ def random_text(nobs=100):
251
251
252
252
df = random_text (100000 )
253
253
indexer = df .letters .apply (lambda x : len (x ) > 10 )
254
- df .ix [indexer , 'letters' ] = df .ix [indexer , 'letters' ].apply (str .lower )
254
+ df .loc [indexer , 'letters' ] = df .loc [indexer , 'letters' ].apply (str .lower )
255
255
256
256
# an identical take, so no copy
257
257
df = DataFrame ({'a' : [1 ]}).dropna ()
@@ -312,12 +312,12 @@ def f():
312
312
D = list ('abcde' )))
313
313
314
314
def f ():
315
- df .ix [2 ]['D' ] = 'foo'
315
+ df .loc [2 ]['D' ] = 'foo'
316
316
317
317
self .assertRaises (com .SettingWithCopyError , f )
318
318
319
319
def f ():
320
- df .ix [2 ]['C' ] = 'foo'
320
+ df .loc [2 ]['C' ] = 'foo'
321
321
322
322
self .assertRaises (com .SettingWithCopyError , f )
323
323
0 commit comments