@@ -393,85 +393,6 @@ def test_boolean_index_empty_corner(self):
393
393
blah [k ]
394
394
blah [k ] = 0
395
395
396
- def test_getitem_ix_mixed_integer (self ):
397
- df = DataFrame (
398
- np .random .randn (4 , 3 ), index = [1 , 10 , "C" , "E" ], columns = [1 , 2 , 3 ]
399
- )
400
-
401
- result = df .iloc [:- 1 ]
402
- expected = df .loc [df .index [:- 1 ]]
403
- assert_frame_equal (result , expected )
404
-
405
- with catch_warnings (record = True ):
406
- simplefilter ("ignore" , FutureWarning )
407
- result = df .ix [[1 , 10 ]]
408
- expected = df .ix [Index ([1 , 10 ], dtype = object )]
409
- assert_frame_equal (result , expected )
410
-
411
- # 11320
412
- df = pd .DataFrame (
413
- {
414
- "rna" : (1.5 , 2.2 , 3.2 , 4.5 ),
415
- - 1000 : [11 , 21 , 36 , 40 ],
416
- 0 : [10 , 22 , 43 , 34 ],
417
- 1000 : [0 , 10 , 20 , 30 ],
418
- },
419
- columns = ["rna" , - 1000 , 0 , 1000 ],
420
- )
421
- result = df [[1000 ]]
422
- expected = df .iloc [:, [3 ]]
423
- assert_frame_equal (result , expected )
424
- result = df [[- 1000 ]]
425
- expected = df .iloc [:, [1 ]]
426
- assert_frame_equal (result , expected )
427
-
428
- def test_getitem_setitem_ix_negative_integers (self , float_frame ):
429
- with catch_warnings (record = True ):
430
- simplefilter ("ignore" , FutureWarning )
431
- result = float_frame .ix [:, - 1 ]
432
- assert_series_equal (result , float_frame ["D" ])
433
-
434
- with catch_warnings (record = True ):
435
- simplefilter ("ignore" , FutureWarning )
436
- result = float_frame .ix [:, [- 1 ]]
437
- assert_frame_equal (result , float_frame [["D" ]])
438
-
439
- with catch_warnings (record = True ):
440
- simplefilter ("ignore" , FutureWarning )
441
- result = float_frame .ix [:, [- 1 , - 2 ]]
442
- assert_frame_equal (result , float_frame [["D" , "C" ]])
443
-
444
- with catch_warnings (record = True ):
445
- simplefilter ("ignore" , FutureWarning )
446
- float_frame .ix [:, [- 1 ]] = 0
447
- assert (float_frame ["D" ] == 0 ).all ()
448
-
449
- df = DataFrame (np .random .randn (8 , 4 ))
450
- # ix does label-based indexing when having an integer index
451
- msg = "\" None of [Int64Index([-1], dtype='int64')] are in the [index]\" "
452
- with catch_warnings (record = True ):
453
- simplefilter ("ignore" , FutureWarning )
454
- with pytest .raises (KeyError , match = re .escape (msg )):
455
- df .ix [[- 1 ]]
456
-
457
- msg = "\" None of [Int64Index([-1], dtype='int64')] are in the [columns]\" "
458
- with catch_warnings (record = True ):
459
- simplefilter ("ignore" , FutureWarning )
460
- with pytest .raises (KeyError , match = re .escape (msg )):
461
- df .ix [:, [- 1 ]]
462
-
463
- # #1942
464
- a = DataFrame (np .random .randn (20 , 2 ), index = [chr (x + 65 ) for x in range (20 )])
465
- with catch_warnings (record = True ):
466
- simplefilter ("ignore" , FutureWarning )
467
- a .ix [- 1 ] = a .ix [- 2 ]
468
-
469
- with catch_warnings (record = True ):
470
- simplefilter ("ignore" , FutureWarning )
471
- assert_series_equal (a .ix [- 1 ], a .ix [- 2 ], check_names = False )
472
- assert a .ix [- 1 ].name == "T"
473
- assert a .ix [- 2 ].name == "S"
474
-
475
396
def test_getattr (self , float_frame ):
476
397
assert_series_equal (float_frame .A , float_frame ["A" ])
477
398
msg = "'DataFrame' object has no attribute 'NONEXISTENT_NAME'"
0 commit comments