BUG: pd.Series.rename(..., inplace=True) returns a pd.Series and not nont #60942
Closed
3 tasks done
Labels
Bug
Docs
good first issue
inplace
Relating to inplace parameter or equivalent
rename
.rename, .rename_axis
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
According to the documation, inplace operations should return None and only modify the object in place without doing a deepcopy.
However when running the rename operation on
pd.Series
withinplace=True
the type of the returns ispd.Series
and not None.This seems to originate from quick look up in the
_set_name
operations that return and object no matter the value ofinplace
(cfpandas/pandas/core/series.py
Lines 1835 to 1850 in 6bcd303
And then the
rename
operation only returns the result of_set_name
without distinguishing theinplace
value.Expected Behavior
The docs suggest that the return of the
rename(..., inplace=True)
should be None.Installed Versions
INSTALLED VERSIONS
commit : 0691c5c
python : 3.13.1
python-bits : 64
OS : Darwin
OS-release : 24.3.0
Version : Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:06 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8103
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.2.3
numpy : 2.1.3
pytz : 2024.2
dateutil : 2.9.0.post0
pip : 24.3.1
Cython : None
sphinx : None
IPython : 8.29.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : None
lxml.etree : None
matplotlib : 3.9.2
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : None
pyreadstat : None
pytest : 8.3.3
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2024.2
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: