Add a .relabel method; deprecate .rename and .rename_axis for relabeling #16990
Labels
API Design
Deprecate
Functionality to remove in pandas
Duplicate Report
Duplicate issue or pull request
This was suggested by @MaximilianR here, but @jorisvandenbossche (rightly) proposed to discuss separately.
This is related to the discussion on
.rename
and.rename_axis
's signatures (see above), but touches a different issue. Currently, these two functions are confusing not just because they do the same thing, but also because they (each) do two different things (renaming axis/object name, and relabeling), and because they do not do the most obvious thing (relabeling by passing a list-like - since a list-like is assumed to refer to multiple names for aMultiIndex
' levels).My proposal is the following:
.relabel
, which changes the content of the axis, as in.rename
and.rename_index
for doing the same operation, that is when theindex
ormapper
argument (respectively) is a callable or dict-like; keep them (or, even better, keep one and deprecate the other) for changing only index namesWhether the signature of
.relabel
should follow theaxis=
orindex=
,column=
standard will depend from the outcome of the discussion aboutrename
andrename_index
(#12392).The text was updated successfully, but these errors were encountered: