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

This issue has been created since 2022-09-23.

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
MarcoGorelli wrote this answer on 2022-09-23

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 wrote this answer on 2022-09-23

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 wrote this answer on 2022-09-23

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

More Details About Repo
Owner Name pandas-dev
Repo Name pandas
Full Name pandas-dev/pandas
Language Python
Created Date 2010-08-24
Updated Date 2022-09-29
Star Count 35374
Watcher Count 1122
Fork Count 15034
Issue Count 3579

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
getUserPrincipals() is missing a "fields" paramater 1 2020-11-13 2022-07-31
More than 80% of all hotspots are witnessing with same maker 0 2022-05-29 2022-06-01
Fails To Build On Pinebook Pro (Manjaro, ARM64) 3 2021-09-05 2022-05-13
Mdl and Sys buttons Strange behavior 5 2022-09-04 2022-09-19
wasm.__wbindgen_add_to_stack_pointer is not a function 4 2022-03-06 2022-09-29
Add module_t::get_kernel() taking a string 0 2022-06-08 2022-09-12
Need ability to render compilation_options_t into a buffer/string 0 2022-06-07 2022-09-12
Make `marshal()` and `render()` independent functions 0 2022-06-07 2022-09-12
[Suggestion] i more idea :) 1 2021-12-03 2022-09-21
Installing npm module on M1 CPU fails 1 2021-07-15 2022-09-27
Add OKLAB to the color addon 1 2021-01-03 2022-08-28
move the dev ckan.ini file to the repo root 0 2021-10-12 2022-09-13
Stream module moving from OCaml stdlib to camlp-stream library 2 2021-07-01 2022-09-27
Iit works on windows 11 home? 7 2021-11-12 2022-07-30
Service installed OK but started WRONG 2 2021-03-24 2022-09-21
Feature Request: SMS/calls extraction on non rooted device with temporary app 0 2021-11-06 2022-08-10
[New mintty version] 3.6.0 2 2022-03-26 2022-09-27
Beacon proxy doesn't point to correct implementation 0 2021-10-15 2022-09-27
Support RetryPolicy.onRetryScheduled 5 2021-07-20 2022-09-22
Panic with concurrent updates to an event stream 0 2021-08-03 2022-09-18
Please add a license file 3 2021-07-03 2022-08-19
Non-blocking feedback for Podcast sponsorship page 1 2022-04-25 2022-09-24
Switch specific water splash behaviour 0 2022-03-27 2022-08-23
Reduce confusion for Rosetta site/non-English users 2 2022-04-06 2022-09-24
Static build error on Windows 0 2022-06-13 2022-09-20
Contribution guidelines and documentation links broken 1 2022-01-25 2022-09-20
Error if the data set already contains a column `y` 4 2021-05-31 2022-09-15
`nix-shell --sandbox` for debugging derivations 3 2022-05-05 2022-08-11
Would like to share my Innovus map file 10 2021-03-27 2022-09-21
Exposing compression method in Entry 3 2021-04-14 2022-09-15
How to push metrics from node_exporter to prometheus server 1 2022-03-03 2022-09-15
Large dataset and really long training time per epoch in Google Colab 13 2022-01-27 2022-08-22
Whenever I "Log In", It just redirects me to the main page without me being logged in. 1 2022-06-29 2022-09-10
[Bug] Failed to compile extension due to the latest setuptools 2 2021-12-24 2022-09-27
UI does not show date and time fields 0 2022-01-31 2022-09-09
Android test with Dagger Hilt 2.38.1 --> error: cannot find symbol import dagger.hilt.android.internal.Contexts; 1 2021-08-15 2022-09-29
Isomorphic IInstaller: Support installing dependencies with the debugger 8 2022-06-28 2022-08-26
Add custom MC-Dev import example 4 2021-06-18 2022-09-23
[DocDB] Improve logging and metrics for tablet split manager 0 2022-06-29 2022-09-27
Word2Vec load giving UnpicklingError: could not find MARK and can't resave? 3 2022-07-27 2022-09-10
Visual Studio Code create a lot of zombie processes 2 2022-05-06 2022-09-14
Unable to change elastic search index's shard values thru configuration 0 2021-10-25 2022-08-09
Unable to configure elastic search queue size 0 2021-10-25 2022-01-26
SaaS offer flow in the Azure commercial marketplace 1 2021-10-26 2022-09-08
Feature Request: JDBC Sink for SQL 2 2022-03-31 2022-09-07
`dependencyBrowseTree` throws `java.lang.OutOfMemoryError` 12 2022-04-26 2022-09-07
[Question]distrubute training 6 2018-12-29 2022-09-18
Error converting multilingual universal sentence encoder to TensorRT. Input 1 of node StatefulPartitionedCall was passed float from statefulpartitionedcall_args_1:0 incompatible with expected resource. 1 2020-11-17 2022-07-13
Backend is not available 2 2022-05-15 2022-09-16
Unable to load assets when reloading the page 1 2022-03-01 2022-09-27