@@ -29,13 +29,11 @@ def test_loc_getitem_label_out_of_range(self):
29
29
30
30
# out of range label
31
31
self .check_result (
32
- "loc" , "f" , typs = ["ints" , "uints" , "labels" , "mixed" , "ts" ], fails = KeyError ,
32
+ "loc" , "f" , typs = ["ints" , "uints" , "labels" , "mixed" , "ts" ], fails = KeyError
33
33
)
34
34
self .check_result ("loc" , "f" , typs = ["floats" ], fails = KeyError )
35
35
self .check_result ("loc" , "f" , typs = ["floats" ], fails = KeyError )
36
- self .check_result (
37
- "loc" , 20 , typs = ["ints" , "uints" , "mixed" ], fails = KeyError ,
38
- )
36
+ self .check_result ("loc" , 20 , typs = ["ints" , "uints" , "mixed" ], fails = KeyError )
39
37
self .check_result ("loc" , 20 , typs = ["labels" ], fails = KeyError )
40
38
self .check_result ("loc" , 20 , typs = ["ts" ], axes = 0 , fails = KeyError )
41
39
self .check_result ("loc" , 20 , typs = ["floats" ], axes = 0 , fails = KeyError )
@@ -46,26 +44,24 @@ def test_loc_getitem_label_list(self):
46
44
pass
47
45
48
46
def test_loc_getitem_label_list_with_missing (self ):
47
+ self .check_result ("loc" , [0 , 1 , 2 ], typs = ["empty" ], fails = KeyError )
49
48
self .check_result (
50
- "loc" , [0 , 1 , 2 ], typs = ["empty" ], fails = KeyError ,
51
- )
52
- self .check_result (
53
- "loc" , [0 , 2 , 10 ], typs = ["ints" , "uints" , "floats" ], axes = 0 , fails = KeyError ,
49
+ "loc" , [0 , 2 , 10 ], typs = ["ints" , "uints" , "floats" ], axes = 0 , fails = KeyError
54
50
)
55
51
56
52
self .check_result (
57
- "loc" , [3 , 6 , 7 ], typs = ["ints" , "uints" , "floats" ], axes = 1 , fails = KeyError ,
53
+ "loc" , [3 , 6 , 7 ], typs = ["ints" , "uints" , "floats" ], axes = 1 , fails = KeyError
58
54
)
59
55
60
56
# GH 17758 - MultiIndex and missing keys
61
57
self .check_result (
62
- "loc" , [(1 , 3 ), (1 , 4 ), (2 , 5 )], typs = ["multi" ], axes = 0 , fails = KeyError ,
58
+ "loc" , [(1 , 3 ), (1 , 4 ), (2 , 5 )], typs = ["multi" ], axes = 0 , fails = KeyError
63
59
)
64
60
65
61
def test_loc_getitem_label_list_fails (self ):
66
62
# fails
67
63
self .check_result (
68
- "loc" , [20 , 30 , 40 ], typs = ["ints" , "uints" ], axes = 1 , fails = KeyError ,
64
+ "loc" , [20 , 30 , 40 ], typs = ["ints" , "uints" ], axes = 1 , fails = KeyError
69
65
)
70
66
71
67
def test_loc_getitem_label_array_like (self ):
@@ -95,18 +91,14 @@ def test_loc_getitem_label_slice(self):
95
91
)
96
92
97
93
self .check_result (
98
- "loc" , slice ("20130102" , "20130104" ), typs = ["ts" ], axes = 1 , fails = TypeError ,
94
+ "loc" , slice ("20130102" , "20130104" ), typs = ["ts" ], axes = 1 , fails = TypeError
99
95
)
100
96
101
- self .check_result (
102
- "loc" , slice (2 , 8 ), typs = ["mixed" ], axes = 0 , fails = TypeError ,
103
- )
104
- self .check_result (
105
- "loc" , slice (2 , 8 ), typs = ["mixed" ], axes = 1 , fails = KeyError ,
106
- )
97
+ self .check_result ("loc" , slice (2 , 8 ), typs = ["mixed" ], axes = 0 , fails = TypeError )
98
+ self .check_result ("loc" , slice (2 , 8 ), typs = ["mixed" ], axes = 1 , fails = KeyError )
107
99
108
100
self .check_result (
109
- "loc" , slice (2 , 4 , 2 ), typs = ["mixed" ], axes = 0 , fails = TypeError ,
101
+ "loc" , slice (2 , 4 , 2 ), typs = ["mixed" ], axes = 0 , fails = TypeError
110
102
)
111
103
112
104
def test_setitem_from_duplicate_axis (self ):
@@ -669,8 +661,7 @@ def test_loc_setitem_with_scalar_index(self, indexer, value):
669
661
(1 , ["A" , "B" , "C" ]),
670
662
np .array ([7 , 8 , 9 ], dtype = np .int64 ),
671
663
pd .DataFrame (
672
- [[1 , 2 , np .nan ], [7 , 8 , 9 ], [5 , 6 , np .nan ]],
673
- columns = ["A" , "B" , "C" ],
664
+ [[1 , 2 , np .nan ], [7 , 8 , 9 ], [5 , 6 , np .nan ]], columns = ["A" , "B" , "C" ]
674
665
),
675
666
),
676
667
(
0 commit comments