Skip to content

Commit 49b7c1d

Browse files
EricLeerJulianWgs
authored andcommitted
TST Add test for iloc on interval index (pandas-dev#40866)
1 parent 88c20fd commit 49b7c1d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pandas/tests/indexing/test_iloc.py

+18
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
CategoricalDtype,
1818
DataFrame,
1919
Index,
20+
Interval,
2021
NaT,
2122
Series,
2223
array,
@@ -1092,6 +1093,23 @@ def test_iloc_getitem_with_duplicates2(self):
10921093
expected = df.take([0], axis=1)
10931094
tm.assert_frame_equal(result, expected)
10941095

1096+
def test_iloc_interval(self):
1097+
# GH#17130
1098+
df = DataFrame({Interval(1, 2): [1, 2]})
1099+
1100+
result = df.iloc[0]
1101+
expected = Series({Interval(1, 2): 1}, name=0)
1102+
tm.assert_series_equal(result, expected)
1103+
1104+
result = df.iloc[:, 0]
1105+
expected = Series([1, 2], name=Interval(1, 2))
1106+
tm.assert_series_equal(result, expected)
1107+
1108+
result = df.copy()
1109+
result.iloc[:, 0] += 1
1110+
expected = DataFrame({Interval(1, 2): [2, 3]})
1111+
tm.assert_frame_equal(result, expected)
1112+
10951113

10961114
class TestILocErrors:
10971115
# NB: this test should work for _any_ Series we can pass as

0 commit comments

Comments
 (0)