@@ -6162,12 +6162,20 @@ def bfill(
61626162 method = "bfill" , axis = axis , inplace = inplace , limit = limit , downcast = downcast
61636163 )
61646164
6165- _shared_docs [
6166- "replace"
6167- ] = """
6165+ @doc (klass = _shared_doc_kwargs ["klass" ])
6166+ def replace (
6167+ self ,
6168+ to_replace = None ,
6169+ value = None ,
6170+ inplace = False ,
6171+ limit = None ,
6172+ regex = False ,
6173+ method = "pad" ,
6174+ ):
6175+ """
61686176 Replace values given in `to_replace` with `value`.
61696177
6170- Values of the %( klass)s are replaced with other values dynamically.
6178+ Values of the { klass} are replaced with other values dynamically.
61716179 This differs from updating with ``.loc`` or ``.iloc``, which require
61726180 you to specify a location to update with some value.
61736181
@@ -6199,19 +6207,19 @@ def bfill(
61996207
62006208 - Dicts can be used to specify different replacement values
62016209 for different existing values. For example,
6202- ``{'a': 'b', 'y': 'z'}`` replaces the value 'a' with 'b' and
6210+ ``{{ 'a': 'b', 'y': 'z'} }`` replaces the value 'a' with 'b' and
62036211 'y' with 'z'. To use a dict in this way the `value`
62046212 parameter should be `None`.
62056213 - For a DataFrame a dict can specify that different values
62066214 should be replaced in different columns. For example,
6207- ``{'a': 1, 'b': 'z'}`` looks for the value 1 in column 'a'
6215+ ``{{ 'a': 1, 'b': 'z'} }`` looks for the value 1 in column 'a'
62086216 and the value 'z' in column 'b' and replaces these values
62096217 with whatever is specified in `value`. The `value` parameter
62106218 should not be ``None`` in this case. You can treat this as a
62116219 special case of passing two lists except that you are
62126220 specifying the column to search in.
62136221 - For a DataFrame nested dictionaries, e.g.,
6214- ``{'a': {'b': np.nan}}``, are read as follows: look in column
6222+ ``{{ 'a': {{ 'b': np.nan}} }}``, are read as follows: look in column
62156223 'a' for the value 'b' and replace it with NaN. The `value`
62166224 parameter should be ``None`` to use a nested dict in this
62176225 way. You can nest regular expressions as well. Note that
@@ -6244,7 +6252,7 @@ def bfill(
62446252 string. Alternatively, this could be a regular expression or a
62456253 list, dict, or array of regular expressions in which case
62466254 `to_replace` must be ``None``.
6247- method : {'pad', 'ffill', 'bfill', `None`}
6255+ method : {{ 'pad', 'ffill', 'bfill', `None`} }
62486256 The method to use when for replacement, when `to_replace` is a
62496257 scalar, list or tuple and `value` is ``None``.
62506258
@@ -6253,7 +6261,7 @@ def bfill(
62536261
62546262 Returns
62556263 -------
6256- %( klass)s
6264+ { klass}
62576265 Object after replacement.
62586266
62596267 Raises
@@ -6279,8 +6287,8 @@ def bfill(
62796287
62806288 See Also
62816289 --------
6282- %( klass)s .fillna : Fill NA values.
6283- %( klass)s .where : Replace values based on boolean condition.
6290+ { klass} .fillna : Fill NA values.
6291+ { klass} .where : Replace values based on boolean condition.
62846292 Series.str.replace : Simple string replacement.
62856293
62866294 Notes
@@ -6312,9 +6320,9 @@ def bfill(
63126320 4 4
63136321 dtype: int64
63146322
6315- >>> df = pd.DataFrame({'A': [0, 1, 2, 3, 4],
6323+ >>> df = pd.DataFrame({{ 'A': [0, 1, 2, 3, 4],
63166324 ... 'B': [5, 6, 7, 8, 9],
6317- ... 'C': ['a', 'b', 'c', 'd', 'e']})
6325+ ... 'C': ['a', 'b', 'c', 'd', 'e']}} )
63186326 >>> df.replace(0, 5)
63196327 A B C
63206328 0 5 5 a
@@ -6351,23 +6359,23 @@ def bfill(
63516359
63526360 **dict-like `to_replace`**
63536361
6354- >>> df.replace({0: 10, 1: 100})
6362+ >>> df.replace({{ 0: 10, 1: 100} })
63556363 A B C
63566364 0 10 5 a
63576365 1 100 6 b
63586366 2 2 7 c
63596367 3 3 8 d
63606368 4 4 9 e
63616369
6362- >>> df.replace({'A': 0, 'B': 5}, 100)
6370+ >>> df.replace({{ 'A': 0, 'B': 5} }, 100)
63636371 A B C
63646372 0 100 100 a
63656373 1 1 6 b
63666374 2 2 7 c
63676375 3 3 8 d
63686376 4 4 9 e
63696377
6370- >>> df.replace({'A': {0: 100, 4: 400}})
6378+ >>> df.replace({{ 'A': {{ 0: 100, 4: 400}} }})
63716379 A B C
63726380 0 100 5 a
63736381 1 1 6 b
@@ -6377,15 +6385,15 @@ def bfill(
63776385
63786386 **Regular expression `to_replace`**
63796387
6380- >>> df = pd.DataFrame({'A': ['bat', 'foo', 'bait'],
6381- ... 'B': ['abc', 'bar', 'xyz']})
6388+ >>> df = pd.DataFrame({{ 'A': ['bat', 'foo', 'bait'],
6389+ ... 'B': ['abc', 'bar', 'xyz']}} )
63826390 >>> df.replace(to_replace=r'^ba.$', value='new', regex=True)
63836391 A B
63846392 0 new abc
63856393 1 foo new
63866394 2 bait xyz
63876395
6388- >>> df.replace({'A': r'^ba.$'}, {'A': 'new'}, regex=True)
6396+ >>> df.replace({{ 'A': r'^ba.$'}} , {{ 'A': 'new'} }, regex=True)
63896397 A B
63906398 0 new abc
63916399 1 foo bar
@@ -6397,7 +6405,7 @@ def bfill(
63976405 1 foo new
63986406 2 bait xyz
63996407
6400- >>> df.replace(regex={r'^ba.$': 'new', 'foo': 'xyz'})
6408+ >>> df.replace(regex={{ r'^ba.$': 'new', 'foo': 'xyz'} })
64016409 A B
64026410 0 new abc
64036411 1 xyz new
@@ -6413,28 +6421,28 @@ def bfill(
64136421 the data types in the `to_replace` parameter must match the data
64146422 type of the value being replaced:
64156423
6416- >>> df = pd.DataFrame({'A': [True, False, True],
6417- ... 'B': [False, True, False]})
6418- >>> df.replace({'a string': 'new value', True: False}) # raises
6424+ >>> df = pd.DataFrame({{ 'A': [True, False, True],
6425+ ... 'B': [False, True, False]}} )
6426+ >>> df.replace({{ 'a string': 'new value', True: False} }) # raises
64196427 Traceback (most recent call last):
64206428 ...
64216429 TypeError: Cannot compare types 'ndarray(dtype=bool)' and 'str'
64226430
64236431 This raises a ``TypeError`` because one of the ``dict`` keys is not of
64246432 the correct type for replacement.
64256433
6426- Compare the behavior of ``s.replace({'a': None})`` and
6434+ Compare the behavior of ``s.replace({{ 'a': None} })`` and
64276435 ``s.replace('a', None)`` to understand the peculiarities
64286436 of the `to_replace` parameter:
64296437
64306438 >>> s = pd.Series([10, 'a', 'a', 'b', 'a'])
64316439
64326440 When one uses a dict as the `to_replace` value, it is like the
64336441 value(s) in the dict are equal to the `value` parameter.
6434- ``s.replace({'a': None})`` is equivalent to
6435- ``s.replace(to_replace={'a': None}, value=None, method=None)``:
6442+ ``s.replace({{ 'a': None} })`` is equivalent to
6443+ ``s.replace(to_replace={{ 'a': None} }, value=None, method=None)``:
64366444
6437- >>> s.replace({'a': None})
6445+ >>> s.replace({{ 'a': None} })
64386446 0 10
64396447 1 None
64406448 2 None
@@ -6457,17 +6465,6 @@ def bfill(
64576465 4 b
64586466 dtype: object
64596467 """
6460-
6461- @Appender (_shared_docs ["replace" ] % _shared_doc_kwargs )
6462- def replace (
6463- self ,
6464- to_replace = None ,
6465- value = None ,
6466- inplace = False ,
6467- limit = None ,
6468- regex = False ,
6469- method = "pad" ,
6470- ):
64716468 if not (
64726469 is_scalar (to_replace )
64736470 or is_re_compilable (to_replace )
@@ -8246,17 +8243,29 @@ def ranker(data):
82468243
82478244 return ranker (data )
82488245
8249- _shared_docs [
8250- "align"
8251- ] = """
8246+ @doc (** _shared_doc_kwargs )
8247+ def align (
8248+ self ,
8249+ other ,
8250+ join = "outer" ,
8251+ axis = None ,
8252+ level = None ,
8253+ copy = True ,
8254+ fill_value = None ,
8255+ method = None ,
8256+ limit = None ,
8257+ fill_axis = 0 ,
8258+ broadcast_axis = None ,
8259+ ):
8260+ """
82528261 Align two objects on their axes with the specified join method.
82538262
82548263 Join method is specified for each axis Index.
82558264
82568265 Parameters
82578266 ----------
82588267 other : DataFrame or Series
8259- join : {'outer', 'inner', 'left', 'right'}, default 'outer'
8268+ join : {{ 'outer', 'inner', 'left', 'right'} }, default 'outer'
82608269 axis : allowed axis of the other object, default None
82618270 Align on index (0), columns (1), or both (None).
82628271 level : int or level name, default None
@@ -8268,7 +8277,7 @@ def ranker(data):
82688277 fill_value : scalar, default np.NaN
82698278 Value to use for missing values. Defaults to NaN, but can be any
82708279 "compatible" value.
8271- method : {'backfill', 'bfill', 'pad', 'ffill', None}, default None
8280+ method : {{ 'backfill', 'bfill', 'pad', 'ffill', None} }, default None
82728281 Method to use for filling holes in reindexed Series:
82738282
82748283 - pad / ffill: propagate last valid observation forward to next valid.
@@ -8281,32 +8290,18 @@ def ranker(data):
82818290 be partially filled. If method is not specified, this is the
82828291 maximum number of entries along the entire axis where NaNs will be
82838292 filled. Must be greater than 0 if not None.
8284- fill_axis : %( axes_single_arg)s , default 0
8293+ fill_axis : { axes_single_arg} , default 0
82858294 Filling axis, method and limit.
8286- broadcast_axis : %( axes_single_arg)s , default None
8295+ broadcast_axis : { axes_single_arg} , default None
82878296 Broadcast values along this axis, if aligning two objects of
82888297 different dimensions.
82898298
82908299 Returns
82918300 -------
8292- (left, right) : (%( klass)s , type of other)
8301+ (left, right) : ({ klass} , type of other)
82938302 Aligned objects.
82948303 """
82958304
8296- @Appender (_shared_docs ["align" ] % _shared_doc_kwargs )
8297- def align (
8298- self ,
8299- other ,
8300- join = "outer" ,
8301- axis = None ,
8302- level = None ,
8303- copy = True ,
8304- fill_value = None ,
8305- method = None ,
8306- limit = None ,
8307- fill_axis = 0 ,
8308- broadcast_axis = None ,
8309- ):
83108305 method = missing .clean_fill_method (method )
83118306
83128307 if broadcast_axis == 1 and self .ndim != other .ndim :
@@ -8850,9 +8845,11 @@ def mask(
88508845 errors = errors ,
88518846 )
88528847
8853- _shared_docs [
8854- "shift"
8855- ] = """
8848+ @doc (klass = _shared_doc_kwargs ["klass" ])
8849+ def shift (
8850+ self : FrameOrSeries , periods = 1 , freq = None , axis = 0 , fill_value = None
8851+ ) -> FrameOrSeries :
8852+ """
88568853 Shift index by desired number of periods with an optional time `freq`.
88578854
88588855 When `freq` is not passed, shift the index without realigning the data.
@@ -8869,7 +8866,7 @@ def mask(
88698866 If `freq` is specified then the index values are shifted but the
88708867 data is not realigned. That is, use `freq` if you would like to
88718868 extend the index when shifting and preserve the original data.
8872- axis : {0 or 'index', 1 or 'columns', None}, default None
8869+ axis : {{ 0 or 'index', 1 or 'columns', None} }, default None
88738870 Shift direction.
88748871 fill_value : object, optional
88758872 The scalar value to use for newly introduced missing values.
@@ -8882,7 +8879,7 @@ def mask(
88828879
88838880 Returns
88848881 -------
8885- %( klass)s
8882+ { klass}
88868883 Copy of input object, shifted.
88878884
88888885 See Also
@@ -8895,9 +8892,9 @@ def mask(
88958892
88968893 Examples
88978894 --------
8898- >>> df = pd.DataFrame({'Col1': [10, 20, 15, 30, 45],
8895+ >>> df = pd.DataFrame({{ 'Col1': [10, 20, 15, 30, 45],
88998896 ... 'Col2': [13, 23, 18, 33, 48],
8900- ... 'Col3': [17, 27, 22, 37, 52]})
8897+ ... 'Col3': [17, 27, 22, 37, 52]}} )
89018898
89028899 >>> df.shift(periods=3)
89038900 Col1 Col2 Col3
@@ -8922,12 +8919,7 @@ def mask(
89228919 2 0 0 0
89238920 3 10 13 17
89248921 4 20 23 27
8925- """
8926-
8927- @Appender (_shared_docs ["shift" ] % _shared_doc_kwargs )
8928- def shift (
8929- self : FrameOrSeries , periods = 1 , freq = None , axis = 0 , fill_value = None
8930- ) -> FrameOrSeries :
8922+ """
89318923 if periods == 0 :
89328924 return self .copy ()
89338925
0 commit comments