Closed
Description
Describe the bug
To remove the name of the index of a Series
, one may call Series.rename_axis(None)
, however mypy
does not recognize None
as a valid argument.
To Reproduce
This code:
import pandas as pd
s1 = pd.Series([1, 2, 3], name="values").rename_axis("index")
s2 = s1.rename_axis(None)
print(f"s1\n{s1}\n\ns2\n{s2}\n\n")
elicits the expected output when run:
s1
index
0 1
1 2
2 3
Name: values, dtype: int64
s2
0 1
1 2
2 3
Name: values, dtype: int64
but mypy
complains with:
foo.py:4: error: No overload variant of "rename_axis" of "Series" matches argument type "None" [call-overload]
foo.py:4: note: Possible overload variants:
foo.py:4: note: def [ListLike: (Sequence[Any], ndarray[Any, Any], Series[Any], Index[Any])] rename_axis(self, mapper: str | bytes | date | datetime | timedelta | <9 more items> = ..., index: str | bytes | date | datetime | timedelta | <11 more items> | None = ..., columns: str | bytes | date | datetime | timedelta | <11 more items> | None = ..., axis: Literal['index', 0] | None = ..., copy: bool = ..., *, inplace: Literal[True]) -> None
foo.py:4: note: def [ListLike: (Sequence[Any], ndarray[Any, Any], Series[Any], Index[Any])] rename_axis(self, mapper: str | bytes | date | datetime | timedelta | <9 more items> = ..., index: str | bytes | date | datetime | timedelta | <11 more items> | None = ..., columns: str | bytes | date | datetime | timedelta | <11 more items> | None = ..., axis: Literal['index', 0] | None = ..., copy: bool = ..., inplace: Literal[False] = ...) -> Series[int]
Found 1 error in 1 file (checked 1 source file)
Please complete the following information:
- OS: macOS 14.7.1
- Python version: 3.12.7
- Mypy version: 1.13.0
- Pandas-stubs version: 2.2.3.241009
- Pandas version: 2.2.3