We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 95d1c6b commit d2e767bCopy full SHA for d2e767b
pandas/tests/indexing/test_multiindex.py
@@ -203,6 +203,27 @@ def test_loc_getitem_array(self):
203
result = x.loc[scalar]
204
tm.assert_series_equal(result, expected)
205
206
+ def test_loc_generator(self):
207
+ index = MultiIndex.from_product([[1, 2, 3], ['A', 'B', 'C']])
208
+ x = Series(index=index, data=range(9), dtype=np.float64)
209
+ y = [1, 3]
210
+
211
+ # getitem:
212
+ expected = Series(
213
+ data=[0, 1, 2, 6, 7, 8],
214
+ index=MultiIndex.from_product([[1, 3], ['A', 'B', 'C']]),
215
+ dtype=np.float64)
216
+ result = x.loc[iter(y)]
217
+ tm.assert_series_equal(result, expected)
218
219
+ # setitem:
220
221
+ data=[9, 10, 11, 3, 4, 5, 12, 13, 14],
222
+ index=index,
223
224
+ x.loc[iter(y)] = range(9, 15)
225
+ tm.assert_series_equal(x, expected)
226
227
def test_iloc_getitem_multiindex(self):
228
mi_labels = DataFrame(np.random.randn(4, 3),
229
columns=[['i', 'i', 'j'], ['A', 'A', 'B']],
0 commit comments