Series.rename_axis(mapper, axis=0, copy=True, inplace=False)
[source]
Alter index and / or columns using input function or functions. A scaler or list-like for mapper
will alter the Index.name
or MultiIndex.names
attribute. A function or dict for mapper
will alter the labels. Function / dict values must be unique (1-to-1). Labels not contained in a dict / Series will be left as-is.
Parameters: |
mapper : scalar, list-like, dict-like or function, optional axis : int or string, default 0 copy : boolean, default True Also copy underlying data inplace : boolean, default False |
---|---|
Returns: |
renamed : type of caller |
See also
pandas.NDFrame.rename
, pandas.Index.rename
>>> df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]}) >>> df.rename_axis("foo") # scalar, alters df.index.name A B foo 0 1 4 1 2 5 2 3 6 >>> df.rename_axis(lambda x: 2 * x) # function: alters labels A B 0 1 4 2 2 5 4 3 6 >>> df.rename_axis({"A": "ehh", "C": "see"}, axis="columns") # mapping ehh B 0 1 4 1 2 5 2 3 6
© 2011–2012 Lambda Foundry, Inc. and PyData Development Team
© 2008–2011 AQR Capital Management, LLC
© 2008–2014 the pandas development team
Licensed under the 3-clause BSD License.
http://pandas.pydata.org/pandas-docs/version/0.19.2/generated/pandas.Series.rename_axis.html