@@ -88,71 +88,51 @@ def test_at_with_duplicate_axes_requires_scalar_lookup(self):
88
88
89
89
class TestAtErrors :
90
90
# TODO: De-duplicate/parametrize
91
- # test_at_series_raises_key_error, test_at_frame_raises_key_error,
92
91
# test_at_series_raises_key_error2, test_at_frame_raises_key_error2
93
92
94
- def test_at_series_raises_key_error (self ):
93
+ def test_at_series_raises_key_error (self , indexer_al ):
95
94
# GH#31724 .at should match .loc
96
95
97
96
ser = Series ([1 , 2 , 3 ], index = [3 , 2 , 1 ])
98
- result = ser .at [1 ]
99
- assert result == 3
100
- result = ser .loc [1 ]
97
+ result = indexer_al (ser )[1 ]
101
98
assert result == 3
102
99
103
100
with pytest .raises (KeyError , match = "a" ):
104
- ser .at ["a" ]
105
- with pytest .raises (KeyError , match = "a" ):
106
- # .at should match .loc
107
- ser .loc ["a" ]
101
+ indexer_al (ser )["a" ]
108
102
109
- def test_at_frame_raises_key_error (self ):
103
+ def test_at_frame_raises_key_error (self , indexer_al ):
110
104
# GH#31724 .at should match .loc
111
105
112
106
df = DataFrame ({0 : [1 , 2 , 3 ]}, index = [3 , 2 , 1 ])
113
107
114
- result = df .at [1 , 0 ]
115
- assert result == 3
116
- result = df .loc [1 , 0 ]
108
+ result = indexer_al (df )[1 , 0 ]
117
109
assert result == 3
118
110
119
111
with pytest .raises (KeyError , match = "a" ):
120
- df .at ["a" , 0 ]
121
- with pytest .raises (KeyError , match = "a" ):
122
- df .loc ["a" , 0 ]
112
+ indexer_al (df )["a" , 0 ]
123
113
124
114
with pytest .raises (KeyError , match = "a" ):
125
- df .at [1 , "a" ]
126
- with pytest .raises (KeyError , match = "a" ):
127
- df .loc [1 , "a" ]
115
+ indexer_al (df )[1 , "a" ]
128
116
129
- def test_at_series_raises_key_error2 (self ):
117
+ def test_at_series_raises_key_error2 (self , indexer_al ):
130
118
# at should not fallback
131
119
# GH#7814
132
120
# GH#31724 .at should match .loc
133
121
ser = Series ([1 , 2 , 3 ], index = list ("abc" ))
134
- result = ser .at ["a" ]
135
- assert result == 1
136
- result = ser .loc ["a" ]
122
+ result = indexer_al (ser )["a" ]
137
123
assert result == 1
138
124
139
125
with pytest .raises (KeyError , match = "^0$" ):
140
- ser .at [0 ]
141
- with pytest .raises (KeyError , match = "^0$" ):
142
- ser .loc [0 ]
126
+ indexer_al (ser )[0 ]
143
127
144
- def test_at_frame_raises_key_error2 (self ):
128
+ def test_at_frame_raises_key_error2 (self , indexer_al ):
145
129
# GH#31724 .at should match .loc
146
130
df = DataFrame ({"A" : [1 , 2 , 3 ]}, index = list ("abc" ))
147
- result = df .at ["a" , "A" ]
148
- assert result == 1
149
- result = df .loc ["a" , "A" ]
131
+ result = indexer_al (df )["a" , "A" ]
150
132
assert result == 1
151
133
152
134
with pytest .raises (KeyError , match = "^0$" ):
153
- df .at ["a" , 0 ]
154
- with pytest .raises (KeyError , match = "^0$" ):
155
- df .loc ["a" , 0 ]
135
+ indexer_al (df )["a" , 0 ]
156
136
157
137
def test_at_getitem_mixed_index_no_fallback (self ):
158
138
# GH#19860
0 commit comments