Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more tests
  • Loading branch information
MarcoGorelli committed Oct 30, 2025
commit 0015e537331430f02c6b7ccc939ac6cc42ea5c51
2 changes: 1 addition & 1 deletion pandas-stubs/core/indexes/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
self, start: SliceType = None, end: SliceType = None, step: int | None = None
): ...
def delete(self, loc: int | AnyArrayLikeInt | Sequence[int]) -> Self: ...
def insert(self, loc: int, item: S1) -> Self: ...
def insert(self, loc: int, item: object) -> Index: ...
def drop(self, labels, errors: IgnoreRaise = "raise") -> Self: ...
@property
def shape(self) -> tuple[int, ...]: ...
Expand Down
13 changes: 13 additions & 0 deletions tests/indexes/test_categoricalindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,16 @@ def test_categoricalindex_reindex() -> None:
reindexed = ci.reindex(["b", "c"])
check(assert_type(reindexed[0], pd.Index), pd.Index)
check(assert_type(reindexed[1], np_1darray[np.intp] | None), np_1darray)


def test_categoricalindex_delete() -> None:
ci = pd.CategoricalIndex(["a", "b"])
check(assert_type(ci.delete(0), "pd.CategoricalIndex[str]"), pd.CategoricalIndex)
check(
assert_type(ci.delete([0, 1]), "pd.CategoricalIndex[str]"), pd.CategoricalIndex
)


def test_categoricalindex_insert() -> None:
ci = pd.CategoricalIndex(["a", "b"])
check(assert_type(ci.insert(0, "c"), pd.Index), pd.Index)
Loading