Skip to content

Commit a2e51bc

Browse files
committed
move test to test_xs.py
1 parent fc9c4cd commit a2e51bc

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

pandas/tests/indexing/multiindex/test_xs.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22
import pytest
33

4-
from pandas import DataFrame, Index, MultiIndex, Series, concat, date_range
4+
from pandas import DataFrame, Index, IndexSlice, MultiIndex, Series, concat, date_range
55
import pandas._testing as tm
66
import pandas.core.common as com
77

@@ -220,6 +220,27 @@ def test_xs_level_series_slice_not_implemented(
220220
s[2000, 3:4]
221221

222222

223+
def test_xs_IndexSlice_argument_not_implemented():
224+
# GH 35301
225+
226+
index = MultiIndex(
227+
levels=[[("foo", "bar", 0), ("foo", "baz", 0), ("foo", "qux", 0)], [0, 1]],
228+
codes=[[0, 0, 1, 1, 2, 2], [0, 1, 0, 1, 0, 1]],
229+
)
230+
231+
series = Series(np.random.randn(6), index=index)
232+
frame = DataFrame(np.random.randn(6, 4), index=index)
233+
234+
msg = (
235+
"Expected label or tuple of labels, got "
236+
r"\(\('foo', 'qux', 0\), slice\(None, None, None\)\)"
237+
)
238+
with pytest.raises(TypeError, match=msg):
239+
frame.xs(IndexSlice[("foo", "qux", 0), :])
240+
with pytest.raises(TypeError, match=msg):
241+
series.xs(IndexSlice[("foo", "qux", 0), :])
242+
243+
223244
def test_series_getitem_multiindex_xs():
224245
# GH6258
225246
dt = list(date_range("20130903", periods=3))

0 commit comments

Comments
 (0)