1
- from warnings import catch_warnings , simplefilter
2
-
3
1
import numpy as np
4
2
import pytest
5
3
9
7
from pandas .util import testing as tm
10
8
11
9
12
- @pytest .mark .filterwarnings ("ignore:\\ n.ix:FutureWarning" )
13
- class TestMultiIndexIx :
14
- def test_frame_setitem_ix (self , multiindex_dataframe_random_data ):
10
+ class TestMultiIndex :
11
+ def test_frame_setitem_loc (self , multiindex_dataframe_random_data ):
15
12
frame = multiindex_dataframe_random_data
16
13
frame .loc [("bar" , "two" ), "B" ] = 5
17
14
assert frame .loc [("bar" , "two" ), "B" ] == 5
@@ -22,16 +19,7 @@ def test_frame_setitem_ix(self, multiindex_dataframe_random_data):
22
19
df .loc [("bar" , "two" ), 1 ] = 7
23
20
assert df .loc [("bar" , "two" ), 1 ] == 7
24
21
25
- with catch_warnings (record = True ):
26
- simplefilter ("ignore" , FutureWarning )
27
- df = frame .copy ()
28
- df .columns = list (range (3 ))
29
- df .ix [("bar" , "two" ), 1 ] = 7
30
- assert df .loc [("bar" , "two" ), 1 ] == 7
31
-
32
- def test_ix_general (self ):
33
-
34
- # ix general issues
22
+ def test_loc_general (self ):
35
23
36
24
# GH 2817
37
25
data = {
@@ -55,7 +43,7 @@ def test_ix_general(self):
55
43
expected = DataFrame ({"amount" : [222 , 333 , 444 ]}, index = index )
56
44
tm .assert_frame_equal (res , expected )
57
45
58
- def test_ix_multiindex_missing_label_raises (self ):
46
+ def test_loc_multiindex_missing_label_raises (self ):
59
47
# GH 21593
60
48
df = DataFrame (
61
49
np .random .randn (3 , 3 ),
@@ -64,12 +52,12 @@ def test_ix_multiindex_missing_label_raises(self):
64
52
)
65
53
66
54
with pytest .raises (KeyError , match = r"^2$" ):
67
- df .ix [2 ]
55
+ df .loc [2 ]
68
56
69
- def test_series_ix_getitem_fancy (
57
+ def test_series_loc_getitem_fancy (
70
58
self , multiindex_year_month_day_dataframe_random_data
71
59
):
72
60
s = multiindex_year_month_day_dataframe_random_data ["A" ]
73
61
expected = s .reindex (s .index [49 :51 ])
74
- result = s .ix [[(2000 , 3 , 10 ), (2000 , 3 , 13 )]]
62
+ result = s .loc [[(2000 , 3 , 10 ), (2000 , 3 , 13 )]]
75
63
tm .assert_series_equal (result , expected )
0 commit comments