Skip to content

ENH: Add to_tuples method to IntervalIndex #538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pandas-stubs/core/indexes/interval.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class IntervalIndex(IntervalMixin, ExtensionIndex, Generic[IntervalT]):
copy: bool = ...,
dtype: IntervalDtype | None = ...,
) -> IntervalIndex[pd.Interval[pd.Timedelta]]: ...
def to_tuples(self, na_tuple: bool = ...) -> pd.Index: ...
@overload
def __contains__(self, key: IntervalT) -> bool: ... # type: ignore[misc]
@overload
Expand Down
5 changes: 5 additions & 0 deletions tests/test_interval_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ def test_from_tuples() -> None:
)


def test_to_tuples() -> None:
ind = pd.IntervalIndex.from_tuples([(0, 1), (1, 2)]).to_tuples()
check(assert_type(ind, pd.Index), pd.Index, tuple)


def test_is_overlapping() -> None:
ind = pd.IntervalIndex.from_tuples([(0, 2), (1, 3), (4, 5)])
check(assert_type(ind.is_overlapping, bool), bool)