Skip to content

Fixed Index.rename() and added test #936

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 5 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion pandas-stubs/core/indexes/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ class Index(IndexOpsMixin[S1]):
@names.setter
def names(self, names: list[_str]): ...
def set_names(self, names, *, level=..., inplace: bool = ...): ...
def rename(self, name, inplace: bool = ...): ...
def rename(self, name, inplace: bool = ...) -> Self: ...
@property
def nlevels(self) -> int: ...
def sortlevel(self, level=..., ascending: bool = ..., sort_remaining=...): ...
Expand Down
5 changes: 5 additions & 0 deletions tests/test_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ def test_str_split() -> None:
check(assert_type(ind.str.split("-"), "pd.Index[str]"), pd.Index)
check(assert_type(ind.str.split("-", expand=True), pd.MultiIndex), pd.MultiIndex)

def test_index_rename() -> None:
ind = pd.Index([1, 2, 3], name="foo")
ind2 = ind.rename("goo")
check(assert_type(ind2, pd.Index), pd.Index)


def test_index_dropna():
idx = pd.Index([1, 2])
Expand Down
Loading