def replace(self, to_replace: Optional[Union[(Any, List, Tuple, Dict)]]=None, value: Optional[Any]=None, inplace: bool=False, limit: Optional[int]=None, regex: bool=False, method: str='pad') -> Optional['DataFrame']:
    '\n        Returns a new DataFrame replacing a value with another value.\n\n        Parameters\n        ----------\n        to_replace : int, float, string, list, tuple or dict\n            Value to be replaced.\n        value : int, float, string, list or tuple\n            Value to use to replace holes. The replacement value must be an int, float,\n            or string.\n            If value is a list or tuple, value should be of the same length with to_replace.\n        inplace : boolean, default False\n            Fill in place (do not create a new object)\n\n        Returns\n        -------\n        DataFrame\n            Object after replacement.\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({"name": [\'Ironman\', \'Captain America\', \'Thor\', \'Hulk\'],\n        ...                    "weapon": [\'Mark-45\', \'Shield\', \'Mjolnir\', \'Smash\']},\n        ...                   columns=[\'name\', \'weapon\'])\n        >>> df\n                      name   weapon\n        0          Ironman  Mark-45\n        1  Captain America   Shield\n        2             Thor  Mjolnir\n        3             Hulk    Smash\n\n        Scalar `to_replace` and `value`\n\n        >>> df.replace(\'Ironman\', \'War-Machine\')\n                      name   weapon\n        0      War-Machine  Mark-45\n        1  Captain America   Shield\n        2             Thor  Mjolnir\n        3             Hulk    Smash\n\n        List like `to_replace` and `value`\n\n        >>> df.replace([\'Ironman\', \'Captain America\'], [\'Rescue\', \'Hawkeye\'], inplace=True)\n        >>> df\n              name   weapon\n        0   Rescue  Mark-45\n        1  Hawkeye   Shield\n        2     Thor  Mjolnir\n        3     Hulk    Smash\n\n        Dicts can be used to specify different replacement values for different existing values\n        To use a dict in this way the value parameter should be None\n\n        >>> df.replace({\'Mjolnir\': \'Stormbuster\'})\n              name       weapon\n        0   Rescue      Mark-45\n        1  Hawkeye       Shield\n        2     Thor  Stormbuster\n        3     Hulk        Smash\n\n        Dict can specify that different values should be replaced in different columns\n        The value parameter should not be None in this case\n\n        >>> df.replace({\'weapon\': \'Mjolnir\'}, \'Stormbuster\')\n              name       weapon\n        0   Rescue      Mark-45\n        1  Hawkeye       Shield\n        2     Thor  Stormbuster\n        3     Hulk        Smash\n\n        Nested dictionaries\n        The value parameter should be None to use a nested dict in this way\n\n        >>> df.replace({\'weapon\': {\'Mjolnir\': \'Stormbuster\'}})\n              name       weapon\n        0   Rescue      Mark-45\n        1  Hawkeye       Shield\n        2     Thor  Stormbuster\n        3     Hulk        Smash\n        '
    if (method != 'pad'):
        raise NotImplementedError("replace currently works only for method='pad")
    if (limit is not None):
        raise NotImplementedError('replace currently works only when limit=None')
    if (regex is not False):
        raise NotImplementedError("replace currently doesn't supports regex")
    inplace = validate_bool_kwarg(inplace, 'inplace')
    if ((value is not None) and (not isinstance(value, (int, float, str, list, tuple, dict)))):
        raise TypeError('Unsupported type {}'.format(type(value).__name__))
    if ((to_replace is not None) and (not isinstance(to_replace, (int, float, str, list, tuple, dict)))):
        raise TypeError('Unsupported type {}'.format(type(to_replace).__name__))
    if (isinstance(value, (list, tuple)) and isinstance(to_replace, (list, tuple))):
        if (len(value) != len(to_replace)):
            raise ValueError('Length of to_replace and value must be same')
    if (isinstance(to_replace, dict) and ((value is not None) or all((isinstance(i, dict) for i in to_replace.values())))):
        to_replace_dict = to_replace

        def op(psser: ps.Series) -> ps.Series:
            if (psser.name in to_replace_dict):
                return psser.replace(to_replace=to_replace_dict[psser.name], value=value, regex=regex)
            else:
                return psser
    else:

        def op(psser: ps.Series) -> ps.Series:
            return psser.replace(to_replace=to_replace, value=value, regex=regex)
    psdf = self._apply_series_op(op)
    if inplace:
        self._update_internal_frame(psdf._internal)
        return None
    else:
        return psdf
Returns a new DataFrame replacing a value with another value.

Parameters
----------
to_replace : int, float, string, list, tuple or dict
    Value to be replaced.
value : int, float, string, list or tuple
    Value to use to replace holes. The replacement value must be an int, float,
    or string.
    If value is a list or tuple, value should be of the same length with to_replace.
inplace : boolean, default False
    Fill in place (do not create a new object)

Returns
-------
DataFrame
    Object after replacement.

Examples
--------
>>> df = ps.DataFrame({"name": ['Ironman', 'Captain America', 'Thor', 'Hulk'],
...                    "weapon": ['Mark-45', 'Shield', 'Mjolnir', 'Smash']},
...                   columns=['name', 'weapon'])
>>> df
              name   weapon
0          Ironman  Mark-45
1  Captain America   Shield
2             Thor  Mjolnir
3             Hulk    Smash

Scalar `to_replace` and `value`

>>> df.replace('Ironman', 'War-Machine')
              name   weapon
0      War-Machine  Mark-45
1  Captain America   Shield
2             Thor  Mjolnir
3             Hulk    Smash

List like `to_replace` and `value`

>>> df.replace(['Ironman', 'Captain America'], ['Rescue', 'Hawkeye'], inplace=True)
>>> df
      name   weapon
0   Rescue  Mark-45
1  Hawkeye   Shield
2     Thor  Mjolnir
3     Hulk    Smash

Dicts can be used to specify different replacement values for different existing values
To use a dict in this way the value parameter should be None

>>> df.replace({'Mjolnir': 'Stormbuster'})
      name       weapon
0   Rescue      Mark-45
1  Hawkeye       Shield
2     Thor  Stormbuster
3     Hulk        Smash

Dict can specify that different values should be replaced in different columns
The value parameter should not be None in this case

>>> df.replace({'weapon': 'Mjolnir'}, 'Stormbuster')
      name       weapon
0   Rescue      Mark-45
1  Hawkeye       Shield
2     Thor  Stormbuster
3     Hulk        Smash

Nested dictionaries
The value parameter should be None to use a nested dict in this way

>>> df.replace({'weapon': {'Mjolnir': 'Stormbuster'}})
      name       weapon
0   Rescue      Mark-45
1  Hawkeye       Shield
2     Thor  Stormbuster
3     Hulk        Smash
def replace(self, to_replace: Optional[Union[(Any, List, Tuple, Dict)]]=None, value: Optional[Any]=None, inplace: bool=False, limit: Optional[int]=None, regex: bool=False, method: str='pad') -> Optional['DataFrame']:
    '\n        Returns a new DataFrame replacing a value with another value.\n\n        Parameters\n        ----------\n        to_replace : int, float, string, list, tuple or dict\n            Value to be replaced.\n        value : int, float, string, list or tuple\n            Value to use to replace holes. The replacement value must be an int, float,\n            or string.\n            If value is a list or tuple, value should be of the same length with to_replace.\n        inplace : boolean, default False\n            Fill in place (do not create a new object)\n\n        Returns\n        -------\n        DataFrame\n            Object after replacement.\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({"name": [\'Ironman\', \'Captain America\', \'Thor\', \'Hulk\'],\n        ...                    "weapon": [\'Mark-45\', \'Shield\', \'Mjolnir\', \'Smash\']},\n        ...                   columns=[\'name\', \'weapon\'])\n        >>> df\n                      name   weapon\n        0          Ironman  Mark-45\n        1  Captain America   Shield\n        2             Thor  Mjolnir\n        3             Hulk    Smash\n\n        Scalar `to_replace` and `value`\n\n        >>> df.replace(\'Ironman\', \'War-Machine\')\n                      name   weapon\n        0      War-Machine  Mark-45\n        1  Captain America   Shield\n        2             Thor  Mjolnir\n        3             Hulk    Smash\n\n        List like `to_replace` and `value`\n\n        >>> df.replace([\'Ironman\', \'Captain America\'], [\'Rescue\', \'Hawkeye\'], inplace=True)\n        >>> df\n              name   weapon\n        0   Rescue  Mark-45\n        1  Hawkeye   Shield\n        2     Thor  Mjolnir\n        3     Hulk    Smash\n\n        Dicts can be used to specify different replacement values for different existing values\n        To use a dict in this way the value parameter should be None\n\n        >>> df.replace({\'Mjolnir\': \'Stormbuster\'})\n              name       weapon\n        0   Rescue      Mark-45\n        1  Hawkeye       Shield\n        2     Thor  Stormbuster\n        3     Hulk        Smash\n\n        Dict can specify that different values should be replaced in different columns\n        The value parameter should not be None in this case\n\n        >>> df.replace({\'weapon\': \'Mjolnir\'}, \'Stormbuster\')\n              name       weapon\n        0   Rescue      Mark-45\n        1  Hawkeye       Shield\n        2     Thor  Stormbuster\n        3     Hulk        Smash\n\n        Nested dictionaries\n        The value parameter should be None to use a nested dict in this way\n\n        >>> df.replace({\'weapon\': {\'Mjolnir\': \'Stormbuster\'}})\n              name       weapon\n        0   Rescue      Mark-45\n        1  Hawkeye       Shield\n        2     Thor  Stormbuster\n        3     Hulk        Smash\n        '
    if (method != 'pad'):
        raise NotImplementedError("replace currently works only for method='pad")
    if (limit is not None):
        raise NotImplementedError('replace currently works only when limit=None')
    if (regex is not False):
        raise NotImplementedError("replace currently doesn't supports regex")
    inplace = validate_bool_kwarg(inplace, 'inplace')
    if ((value is not None) and (not isinstance(value, (int, float, str, list, tuple, dict)))):
        raise TypeError('Unsupported type {}'.format(type(value).__name__))
    if ((to_replace is not None) and (not isinstance(to_replace, (int, float, str, list, tuple, dict)))):
        raise TypeError('Unsupported type {}'.format(type(to_replace).__name__))
    if (isinstance(value, (list, tuple)) and isinstance(to_replace, (list, tuple))):
        if (len(value) != len(to_replace)):
            raise ValueError('Length of to_replace and value must be same')
    if (isinstance(to_replace, dict) and ((value is not None) or all((isinstance(i, dict) for i in to_replace.values())))):
        to_replace_dict = to_replace

        def op(psser: ps.Series) -> ps.Series:
            if (psser.name in to_replace_dict):
                return psser.replace(to_replace=to_replace_dict[psser.name], value=value, regex=regex)
            else:
                return psser
    else:

        def op(psser: ps.Series) -> ps.Series:
            return psser.replace(to_replace=to_replace, value=value, regex=regex)
    psdf = self._apply_series_op(op)
    if inplace:
        self._update_internal_frame(psdf._internal)
        return None
    else:
        return psdf