From c1e91f97fc5d59495878198af7f953e8cf6d9ada Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Sat, 10 Mar 2018 12:36:59 +0100 Subject: [PATCH 1/2] DOC: update pandas.Series.rename_axis --- pandas/core/generic.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index a893b2ba1a189..70918039b3459 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -913,20 +913,24 @@ def f(x): rename.__doc__ = _shared_docs['rename'] def rename_axis(self, mapper, axis=0, copy=True, inplace=False): - """Alter the name of the index or columns. + """ + Alter the name of the index or columns. Parameters ---------- mapper : scalar, list-like, optional Value to set the axis name attribute. - axis : int or string, default 0 + axis : {0 or 'index', 1 or 'columns'}, default 0 + The index or the name of the axis. copy : boolean, default True - Also copy underlying data + Also copy underlying data. inplace : boolean, default False + Modifies the mapper in place. Returns ------- - renamed : type of caller or None if inplace=True + renamed : Series, DataFrame, or None + The same type as the caller or None ifa` inplace` is True. Notes ----- @@ -937,12 +941,12 @@ def rename_axis(self, mapper, axis=0, copy=True, inplace=False): See Also -------- - pandas.Series.rename, pandas.DataFrame.rename - pandas.Index.rename + pandas.Series.rename : Alter Series index labels or name + pandas.DataFrame.rename : Alter DataFrame index labels or name + pandas.Index.rename : Set new names on index Examples -------- - >>> df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]}) >>> df.rename_axis("foo") A B @@ -956,7 +960,6 @@ def rename_axis(self, mapper, axis=0, copy=True, inplace=False): 0 1 4 1 2 5 2 3 6 - """ inplace = validate_bool_kwarg(inplace, 'inplace') non_mapper = is_scalar(mapper) or (is_list_like(mapper) and not From 9d6755f95ea8550679471aa85c21efb14a505aec Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Tue, 13 Mar 2018 16:22:09 -0500 Subject: [PATCH 2/2] Update [ci skip] [ci skip] --- pandas/core/generic.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 70918039b3459..e276cc9abfdf2 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -919,18 +919,19 @@ def rename_axis(self, mapper, axis=0, copy=True, inplace=False): Parameters ---------- mapper : scalar, list-like, optional - Value to set the axis name attribute. + Value to set as the axis name attribute. axis : {0 or 'index', 1 or 'columns'}, default 0 The index or the name of the axis. copy : boolean, default True Also copy underlying data. inplace : boolean, default False - Modifies the mapper in place. + Modifies the object directly, instead of creating a new Series + or DataFrame. Returns ------- renamed : Series, DataFrame, or None - The same type as the caller or None ifa` inplace` is True. + The same type as the caller or None if `inplace` is True. Notes ----- @@ -947,6 +948,18 @@ def rename_axis(self, mapper, axis=0, copy=True, inplace=False): Examples -------- + **Series** + + >>> s = pd.Series([1, 2, 3]) + >>> s.rename_axis("foo") + foo + 0 1 + 1 2 + 2 3 + dtype: int64 + + **DataFrame** + >>> df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]}) >>> df.rename_axis("foo") A B