Skip to content

Commit 276211a

Browse files
committed
GH 25298: Add test for interval index in multiindex
1 parent 6583c1d commit 276211a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/tests/indexing/multiindex/test_multiindex.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
CategoricalDtype,
99
DataFrame,
1010
Index,
11+
Interval,
12+
IntervalIndex,
1113
MultiIndex,
1214
Series,
1315
)
@@ -292,3 +294,13 @@ def test_multiindex_assign_alignment_with_non_string_dtype(self):
292294
)
293295

294296
tm.assert_frame_equal(meta, result)
297+
298+
def test_multiindex_with_interval_index(self):
299+
# for https://github.com/pandas-dev/pandas/issues/25298
300+
intIndex = IntervalIndex.from_arrays([1,5,8,13,16], [4,9,12,17,20])
301+
multiIndex = MultiIndex.from_arrays([["a", "a", "b", "b", "c"], intIndex])
302+
data = [(1,2),(3,4),(5,6),(7,8), (9,10)]
303+
df = DataFrame(data, index=multiIndex)
304+
series1 = df.loc[("b", 16)]
305+
series2 = df.loc["b"].loc[16]
306+
tm.assert_equal(series1.array, series2.array)

0 commit comments

Comments
 (0)