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