Add method to change the .name attribute on the axes · Issue #11965 · pandas-dev/pandas (original) (raw)

It would be nice to have a method to change the .name attribute on the columns/index, to permit it in a method chain. (This is a suggestion based on this stackoverflow question.)

Instead of

df.columns.name = 'A'
df.index.name = 'B'
df
    A   0   1
    B        
    0   9   4
    1  15   0
    2  17  16

it would allow something like

df.rename_columns('A').rename_index('B')

or perhaps be a keyword argument to the existing .rename(). Does this seem like something that would fit in with pandas?