@@ -488,7 +488,7 @@ def _expand_axes(self, key):
488488 Returns
489489 -------
490490 renamed : %(klass)s or None
491- New object if inplace=False, None otherwise.
491+ An object of same type as caller if inplace=False, None otherwise.
492492
493493 See Also
494494 --------
@@ -502,23 +502,23 @@ def _expand_axes(self, key):
502502 1 2
503503 2 3
504504 dtype: int64
505- >>> s.set_axis(0, ['a', 'b', 'c'], inplace=False)
505+ >>> s.set_axis(['a', 'b', 'c'], axis=0 , inplace=False)
506506 a 1
507507 b 2
508508 c 3
509509 dtype: int64
510510 >>> df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
511- >>> df.set_axis(0, ['a', 'b', 'c'], inplace=False)
511+ >>> df.set_axis(['a', 'b', 'c'], axis=0 , inplace=False)
512512 A B
513513 a 1 4
514514 b 2 5
515515 c 3 6
516- >>> df.set_axis(1, ['I', 'II'], inplace=False)
516+ >>> df.set_axis(['I', 'II'], axis=1 , inplace=False)
517517 I II
518518 0 1 4
519519 1 2 5
520520 2 3 6
521- >>> df.set_axis(1, ['i', 'ii'], inplace=True)
521+ >>> df.set_axis(['i', 'ii'], axis=1 , inplace=True)
522522 >>> df
523523 i ii
524524 0 1 4
@@ -531,18 +531,18 @@ def _expand_axes(self, key):
531531 def set_axis (self , labels , axis = 0 , inplace = None ):
532532 if is_scalar (labels ):
533533 warnings .warn (
534- " set_axis now takes \ " labels\ " as first argument, and "
535- " \" axis\ " as named parameter. The old form, with \ " axis\ " as "
536- " first parameter and \" labels\" as second, is still supported "
537- " but will be deprecated in a future version of pandas." ,
534+ ' set_axis now takes "labels" as first argument, and '
535+ '" axis" as named parameter. The old form, with "axis" as '
536+ ' first parameter and \" labels\" as second, is still supported '
537+ ' but will be deprecated in a future version of pandas.' ,
538538 FutureWarning , stacklevel = 2 )
539539 labels , axis = axis , labels
540540
541541 if inplace is None :
542542 warnings .warn (
543- " set_axis currently defaults to operating inplace.\n This "
544- " will change in a future version of pandas, use "
545- " inplace=True to avoid this warning." ,
543+ ' set_axis currently defaults to operating inplace.\n This '
544+ ' will change in a future version of pandas, use '
545+ ' inplace=True to avoid this warning.' ,
546546 FutureWarning , stacklevel = 2 )
547547 inplace = True
548548 if inplace :
@@ -957,7 +957,7 @@ def _set_axis_name(self, name, axis=0, inplace=False):
957957
958958 inplace = validate_bool_kwarg (inplace , 'inplace' )
959959 renamed = self if inplace else self .copy ()
960- renamed .set_axis (axis , idx )
960+ renamed .set_axis (idx , axis = axis , inplace = True )
961961 if not inplace :
962962 return renamed
963963
@@ -5845,7 +5845,7 @@ def slice_shift(self, periods=1, axis=0):
58455845
58465846 new_obj = self ._slice (vslicer , axis = axis )
58475847 shifted_axis = self ._get_axis (axis )[islicer ]
5848- new_obj .set_axis (axis , shifted_axis )
5848+ new_obj .set_axis (shifted_axis , axis = axis , inplace = True )
58495849
58505850 return new_obj .__finalize__ (self )
58515851
@@ -6005,7 +6005,7 @@ def _tz_convert(ax, tz):
60056005 ax = _tz_convert (ax , tz )
60066006
60076007 result = self ._constructor (self ._data , copy = copy )
6008- result .set_axis (axis , ax )
6008+ result .set_axis (ax , axis = axis , inplace = True )
60096009 return result .__finalize__ (self )
60106010
60116011 @deprecate_kwarg (old_arg_name = 'infer_dst' , new_arg_name = 'ambiguous' ,
@@ -6073,7 +6073,7 @@ def _tz_localize(ax, tz, ambiguous):
60736073 ax = _tz_localize (ax , tz , ambiguous )
60746074
60756075 result = self ._constructor (self ._data , copy = copy )
6076- result .set_axis (axis , ax )
6076+ result .set_axis (ax , axis = axis , inplace = True )
60776077 return result .__finalize__ (self )
60786078
60796079 # ----------------------------------------------------------------------
0 commit comments