Skip to content

Commit 6d28a28

Browse files
authored
ENH: Add to_tuples method to IntervalIndex (#538)
Add to_tuples method to IntervalIndex
1 parent 9f4013b commit 6d28a28

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

pandas-stubs/core/indexes/interval.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ class IntervalIndex(IntervalMixin, Generic[IntervalT]):
210210
copy: bool = ...,
211211
dtype: IntervalDtype | None = ...,
212212
) -> IntervalIndex[pd.Interval[pd.Timedelta]]: ...
213+
def to_tuples(self, na_tuple: bool = ...) -> pd.Index: ...
213214
@overload
214215
def __contains__(self, key: IntervalT) -> bool: ... # type: ignore[misc]
215216
@overload

tests/test_interval_index.py

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ def test_from_tuples() -> None:
3333
)
3434

3535

36+
def test_to_tuples() -> None:
37+
ind = pd.IntervalIndex.from_tuples([(0, 1), (1, 2)]).to_tuples()
38+
check(assert_type(ind, pd.Index), pd.Index, tuple)
39+
40+
3641
def test_is_overlapping() -> None:
3742
ind = pd.IntervalIndex.from_tuples([(0, 2), (1, 3), (4, 5)])
3843
check(assert_type(ind.is_overlapping, bool), bool)

0 commit comments

Comments
 (0)