Skip to content

BUG: Incorrect inspect.signature(pd.DataFrame.rename_axis) - missing inplace #48730

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

Closed
3 tasks done
vnlitvinov opened this issue Sep 23, 2022 · 3 comments
Closed
3 tasks done
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@vnlitvinov
Copy link
Contributor

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

import pandas as pd
import inspect
df = pd.DataFrame({'a': [0, 1]})
df.rename_axis('b', inplace=True)
print(df.index.name) # prints 'b', so rename was successful
print('copy' in inspect.signature(df.rename_axis).parameters) # prints True
print('inplace' in inspect.signature(df.rename_axis).parameters) # prints False which is an error

Issue Description

I believe the problem is with the decorator which does not specify inplace in extra arguments (alongside with copy):

pandas/pandas/core/generic.py

Lines 1150 to 1157 in 7d852a9

@rewrite_axis_style_signature("mapper", [("copy", True)])
@deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "mapper"])
def rename_axis(
self: NDFrameT,
mapper: IndexLabel | lib.NoDefault = lib.no_default,
inplace: bool_t = False,
**kwargs,
) -> NDFrameT | None:

That inplace argument works just fine, as my example above shows.

This issue breaks Modin tests which verify the mutual equality of Modin and pandas API for DataFrames.

Expected Behavior

inspect.signature() should indicate that inplace is a supported argument for pd.DataFrame.rename_axis.

Installed Versions

pd.show_versions()
INSTALLED VERSIONS
------------------
commit           : 87cfe4e38bafe7300a6003a1d18bd80f3f77c763
python           : 3.8.13.final.0
python-bits      : 64
OS               : Windows
OS-release       : 10
Version          : 10.0.22000
machine          : AMD64
processor        : AMD64 Family 25 Model 80 Stepping 0, AuthenticAMD
byteorder        : little
LC_ALL           : None
LANG             : None
LOCALE           : Russian_Russia.1251

pandas           : 1.5.0
numpy            : 1.23.3
pytz             : 2022.2.1
dateutil         : 2.8.2
setuptools       : 65.3.0
pip              : 22.2.2
Cython           : None
pytest           : None
hypothesis       : None
sphinx           : None
blosc            : None
feather          : None
xlsxwriter       : None
lxml.etree       : None
html5lib         : None
pymysql          : None
psycopg2         : None
jinja2           : None
IPython          : None
pandas_datareader: None
bs4              : None
bottleneck       : None
brotli           : None
fastparquet      : None
fsspec           : None
gcsfs            : None
matplotlib       : None
numba            : None
numexpr          : None
odfpy            : None
openpyxl         : None
pandas_gbq       : None
pyarrow          : None
pyreadstat       : None
pyxlsb           : None
s3fs             : None
scipy            : None
snappy           : None
sqlalchemy       : None
tables           : None
tabulate         : None
xarray           : None
xlrd             : None
xlwt             : None
zstandard        : None
tzdata           : None
@vnlitvinov vnlitvinov added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 23, 2022
@MarcoGorelli
Copy link
Member

Thanks @vnlitvinov for the report - looks like this is a duplicate of #48692, so closing for now, but please do let me know if you disagree and I should reopen

@vnlitvinov
Copy link
Contributor Author

I'm not sure if that one is a duplicate, but PR there seems to be fixing the issue I'm seeing based on looking on the code (did not try to run that). Thanks!

@MarcoGorelli
Copy link
Member

yeah sorry that's what I meant, the root cause of that one causes what you're seeing here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

2 participants