def replace(self, to_replace, value, inplace=False, filter=None,<EOL>regex=False, convert=True):
inplace = validate_bool_kwarg(inplace, '<STR_LIT>')<EOL>original_to_replace = to_replace<EOL>try:<EOL><INDENT>values, to_replace = self._try_coerce_args(self.values,<EOL>to_replace)<EOL>mask = missing.mask_missing(values, to_replace)<EOL>if filter is not None:<EOL><INDENT>filtered_out = ~self.mgr_locs.isin(filter)<EOL>mask[filtered_out.nonzero()[<NUM_LIT:0>]] = False<EOL><DEDENT>blocks = self.putmask(mask, value, inplace=inplace)<EOL>if convert:<EOL><INDENT>blocks = [b.convert(by_item=True, numeric=False,<EOL>copy=not inplace) for b in blocks]<EOL><DEDENT>return blocks<EOL><DEDENT>except (TypeError, ValueError):<EOL><INDENT>if is_object_dtype(self):<EOL><INDENT>raise<EOL><DEDENT>block = self.astype(object)<EOL>return block.replace(to_replace=original_to_replace,<EOL>value=value,<EOL>inplace=inplace,<EOL>filter=filter,<EOL>regex=regex,<EOL>convert=convert)<EOL><DEDENT>
replace the to_replace value with value, possible to create new
        blocks here this is just a call to putmask. regex is not used here.
        It is used in ObjectBlocks.  It is here for API compatibility.